LCOV - code coverage report
Current view: top level - libreoffice/sw/inc - unoatxt.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 8 0.0 %
Date: 2012-12-27 Functions: 0 5 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             : #ifndef _UNOATXT_HXX
      20             : #define _UNOATXT_HXX
      21             : 
      22             : #include <com/sun/star/text/XAutoTextGroup.hpp>
      23             : #include <com/sun/star/text/XAutoTextEntry.hpp>
      24             : #include <com/sun/star/text/XAutoTextContainer.hpp>
      25             : #include <com/sun/star/text/XText.hpp>
      26             : #include <com/sun/star/lang/XServiceInfo.hpp>
      27             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      28             : #include <com/sun/star/container/XNamed.hpp>
      29             : #include <com/sun/star/container/XIndexAccess.hpp>
      30             : #include <com/sun/star/beans/XPropertySet.hpp>
      31             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      32             : #include <com/sun/star/document/XEventsSupplier.hpp>
      33             : #include <svl/itemprop.hxx>
      34             : #include <svl/lstner.hxx>
      35             : #include <cppuhelper/implbase3.hxx> // helper for implementations
      36             : #include <cppuhelper/implbase4.hxx> // helper for implementations
      37             : #include <cppuhelper/implbase5.hxx> // helper for implementations
      38             : #include <cppuhelper/implbase6.hxx> // helper for implementations
      39             : #include <svtools/unoevent.hxx>
      40             : class SwTextBlocks;
      41             : class SwGlossaries;
      42             : class SwDoc;
      43             : class SwDocShell;
      44             : class SwXBodyText;
      45             : 
      46             : #ifndef SW_DECL_SWDOCSHELL_DEFINED
      47             : #define SW_DECL_SWDOCSHELL_DEFINED
      48             : #include <tools/ref.hxx>
      49             : SV_DECL_REF( SwDocShell )
      50             : #endif
      51             : 
      52             : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
      53             :     SAL_CALL SwXAutoTextContainer_createInstance(
      54             :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw ( ::com::sun::star::uno::Exception );
      55             : 
      56             : class SwXAutoTextContainer : public cppu::WeakImplHelper3
      57             : <
      58             :     ::com::sun::star::text::XAutoTextContainer,
      59             :     ::com::sun::star::lang::XServiceInfo,
      60             :     ::com::sun::star::container::XIndexAccess
      61             : >
      62             : {
      63             :     SwGlossaries *pGlossaries;
      64             : 
      65             : protected:
      66             :     virtual ~SwXAutoTextContainer();    // ref-counted objects are not to be deleted from outside -> protected dtor
      67             : 
      68             : public:
      69             :     SwXAutoTextContainer();
      70             : 
      71             :     //XIndexAccess
      72             :     virtual sal_Int32 SAL_CALL getCount(  ) throw(::com::sun::star::uno::RuntimeException);
      73             :     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
      74             : 
      75             :     //XNameAccess
      76             :     virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name)  throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
      77             :     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException );
      78             :     virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException );
      79             : 
      80             :     //XElementAccess
      81             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException);
      82             :     virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
      83             : 
      84             :     //XAutoTextContainer
      85             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup >  SAL_CALL insertNewByName(const rtl::OUString& aGroupName) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException );
      86             :     virtual void SAL_CALL removeByName(const rtl::OUString& aGroupName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException );
      87             : 
      88             :     //XServiceInfo
      89             :     virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
      90             :     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
      91             :     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
      92             : 
      93             : };
      94             : 
      95             : class SwXAutoTextGroup : public cppu::WeakImplHelper6
      96             : <
      97             :     ::com::sun::star::text::XAutoTextGroup,
      98             :     ::com::sun::star::beans::XPropertySet,
      99             :     ::com::sun::star::lang::XServiceInfo,
     100             :     ::com::sun::star::container::XIndexAccess,
     101             :     ::com::sun::star::container::XNamed,
     102             :     ::com::sun::star::lang::XUnoTunnel
     103             : >
     104             : {
     105             :     const SfxItemPropertySet* pPropSet;
     106             :     SwGlossaries*           pGlossaries;
     107             :     rtl::OUString           sName;
     108             :     String                  m_sGroupName;   // prefix m_ to disambiguate from some local vars in the implementation
     109             : 
     110             : protected:
     111             :     virtual ~SwXAutoTextGroup();    // ref-counted objects are not to be deleted from outside -> protected dtor
     112             : 
     113             : public:
     114             :         SwXAutoTextGroup(const rtl::OUString& rName, SwGlossaries* pGloss);
     115             : 
     116             : 
     117             :     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
     118             : 
     119             :     //XUnoTunnel
     120             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
     121             : 
     122             :     //XAutoTextGroup
     123             :     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getTitles(void) throw( ::com::sun::star::uno::RuntimeException );
     124             :     virtual void SAL_CALL renameByName(const rtl::OUString& aElementName, const rtl::OUString& aNewElementName, const rtl::OUString& aNewElementTitle) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
     125             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry >  SAL_CALL insertNewByName(const rtl::OUString& aName, const rtl::OUString& aTitle, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException );
     126             :     virtual void SAL_CALL removeByName(const rtl::OUString& aEntryName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException );
     127             : 
     128             :     //XNamed
     129             :     virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException );
     130             :     virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException );
     131             : 
     132             :     //XIndexAccess
     133             :     virtual sal_Int32 SAL_CALL getCount(  ) throw(::com::sun::star::uno::RuntimeException);
     134             :     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
     135             : 
     136             :     //XNameAccess
     137             :     virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name)  throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
     138             :     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException );
     139             :     virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException );
     140             : 
     141             :     //XElementAccess
     142             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException);
     143             :     virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
     144             : 
     145             :     //XServiceInfo
     146             :     virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
     147             :     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
     148             :     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
     149             : 
     150             :     //XPropertySet
     151             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
     152             :     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     153             :     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     154             :     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     155             :     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     156             :     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     157             :     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     158             : 
     159             :     //
     160             :     void    Invalidate();
     161             : };
     162             : 
     163             : class SwXAutoTextEntry
     164             :         :public SfxListener
     165             :         ,public cppu::WeakImplHelper5
     166             :         <
     167             :             ::com::sun::star::text::XAutoTextEntry,
     168             :             ::com::sun::star::lang::XServiceInfo,
     169             :             ::com::sun::star::lang::XUnoTunnel,
     170             :             ::com::sun::star::text::XText,
     171             :             ::com::sun::star::document::XEventsSupplier
     172             :         >
     173             : {
     174             :     SwGlossaries*   pGlossaries;
     175             :     String          sGroupName;
     176             :     String          sEntryName;
     177             :     SwDocShellRef   xDocSh;
     178             :     SwXBodyText*    pBodyText;
     179             :     com::sun::star::uno::Reference < com::sun::star::lang::XServiceInfo> xBodyText;
     180             : 
     181           0 :     void EnsureBodyText ()
     182             :     {
     183           0 :         if ( !pBodyText )
     184           0 :             GetBodyText();
     185           0 :     }
     186             :     void GetBodyText ();
     187             : 
     188             : protected:
     189             :     /** ensure that the current content (which may only be in-memory so far) is flushed to the auto text group file
     190             : 
     191             :         <p>If somebody modifies an auto text via this class, then this is not directly reflected to the respective
     192             :         glossaries file (on disk), instead we hold a copy of this text (in [p|x]BodyText). On the other hand,
     193             :         in applyTo, we do not work with this _copy_, but just tell the target for the application to insert
     194             :         the content which we're responsible for - and this target doesn't know about our copy, but only
     195             :         about the persistent version.</br>
     196             :         So we need to ensure that before somebody else does something with our auto text, we flush our
     197             :         (in-memory) copy to disk.</p>
     198             : 
     199             :     */
     200             :     void    implFlushDocument( bool _bCloseDoc = false );
     201             : 
     202             :     // SfxListener overridables
     203             :     virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     204             : 
     205             : protected:
     206             :     virtual ~SwXAutoTextEntry();    // ref-counted objects are not to be deleted from outside -> protected dtor
     207             : 
     208             : public:
     209             :     SwXAutoTextEntry(SwGlossaries* , const String& rGroupName, const String& rEntryName);
     210             : 
     211             :     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
     212             : 
     213             :     //XUnoTunnel
     214             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
     215             : 
     216             :     //XText
     217             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor >  SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException );
     218             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor >  SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException );
     219             :     virtual void SAL_CALL insertString(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const rtl::OUString& aString, sal_Bool bAbsorb) throw( ::com::sun::star::uno::RuntimeException );
     220             :     virtual void SAL_CALL insertControlCharacter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
     221             :     virtual void SAL_CALL insertTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent, sal_Bool bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
     222             :     virtual void SAL_CALL removeTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
     223             : 
     224             :     //XTextRange
     225             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >  SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException );
     226             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL  getStart(void) throw( ::com::sun::star::uno::RuntimeException );
     227             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL   getEnd(void) throw( ::com::sun::star::uno::RuntimeException );
     228             :     virtual rtl::OUString SAL_CALL  getString(void) throw( ::com::sun::star::uno::RuntimeException );
     229             :     virtual void SAL_CALL  setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException );
     230             : 
     231             :     //XAutoTextEntry
     232             :     virtual void    SAL_CALL applyTo(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange)throw( ::com::sun::star::uno::RuntimeException );
     233             : 
     234             :     //XServiceInfo
     235             :     virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
     236             :     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
     237             :     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
     238             : 
     239             :     // XEventsSupplier
     240             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents(  ) throw( ::com::sun::star::uno::RuntimeException );
     241             : 
     242           0 :     void    Invalidate() {pGlossaries = 0;}
     243           0 :     const SwGlossaries* GetGlossaries() { return pGlossaries; }
     244           0 :     const String&   GetGroupName() {return sGroupName;}
     245           0 :     const String&   GetEntryName() {return sEntryName;}
     246             : };
     247             : 
     248             : 
     249             : /** Implement the XNameAccess for the AutoText events */
     250             : class SwAutoTextEventDescriptor : public SvBaseEventDescriptor
     251             : {
     252             :     ::rtl::OUString sSwAutoTextEventDescriptor;
     253             : 
     254             :     SwXAutoTextEntry& rAutoTextEntry;
     255             : 
     256             :     using SvBaseEventDescriptor::replaceByName;
     257             :     using SvBaseEventDescriptor::getByName;
     258             : 
     259             : public:
     260             :     SwAutoTextEventDescriptor(  SwXAutoTextEntry& rAutoText );
     261             : 
     262             :     ~SwAutoTextEventDescriptor();
     263             : 
     264             :     virtual rtl::OUString SAL_CALL getImplementationName(void)
     265             :         throw( ::com::sun::star::uno::RuntimeException );
     266             : 
     267             : protected:
     268             : 
     269             :     virtual void replaceByName(
     270             :         const sal_uInt16 nEvent,        /// item ID of event
     271             :         const SvxMacro& rMacro)     /// event (will be copied)
     272             :             throw(
     273             :                 ::com::sun::star::lang::IllegalArgumentException,
     274             :                 ::com::sun::star::container::NoSuchElementException,
     275             :                 ::com::sun::star::lang::WrappedTargetException,
     276             :                 ::com::sun::star::uno::RuntimeException);
     277             : 
     278             :     virtual void getByName(
     279             :         SvxMacro& rMacro,           /// macro to be filled
     280             :         const sal_uInt16 nEvent )       /// item ID of event
     281             :             throw(
     282             :                 ::com::sun::star::container::NoSuchElementException,
     283             :                 ::com::sun::star::lang::WrappedTargetException,
     284             :                 ::com::sun::star::uno::RuntimeException);
     285             : };
     286             : 
     287             : 
     288             : #endif
     289             : 
     290             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10