LCOV - code coverage report
Current view: top level - sc/inc - textuno.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 7 12 58.3 %
Date: 2014-11-03 Functions: 7 12 58.3 %
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             : #ifndef INCLUDED_SC_INC_TEXTUNO_HXX
      21             : #define INCLUDED_SC_INC_TEXTUNO_HXX
      22             : 
      23             : #include "global.hxx"
      24             : #include "address.hxx"
      25             : #include <editeng/unotext.hxx>
      26             : #include <svl/lstner.hxx>
      27             : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
      28             : #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
      29             : #include <com/sun/star/lang/XServiceInfo.hpp>
      30             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      31             : #include <cppuhelper/implbase3.hxx>
      32             : #include <cppuhelper/implbase5.hxx>
      33             : 
      34             : #include <rtl/ref.hxx>
      35             : #include "scdllapi.h"
      36             : 
      37             : #include <boost/noncopyable.hpp>
      38             : 
      39             : class EditEngine;
      40             : class EditTextObject;
      41             : class SvxEditEngineForwarder;
      42             : class ScDocShell;
      43             : class ScAddress;
      44             : class ScCellObj;
      45             : class ScSimpleEditSource;
      46             : class ScCellEditSource;
      47             : class ScEditEngineDefaulter;
      48             : class ScFieldEditEngine;
      49             : class ScHeaderFooterTextObj;
      50             : 
      51             : struct ScHeaderFieldData;
      52             : 
      53             : #define SC_HDFT_LEFT    0
      54             : #define SC_HDFT_CENTER  1
      55             : #define SC_HDFT_RIGHT   2
      56             : 
      57             : //  ScHeaderFooterContentObj is a dumb container which must be re-written into
      58             : //  the page template using setPropertyValue
      59             : 
      60             : class ScHeaderFooterContentObj : public cppu::WeakImplHelper3<
      61             :                             com::sun::star::sheet::XHeaderFooterContent,
      62             :                             com::sun::star::lang::XUnoTunnel,
      63             :                             com::sun::star::lang::XServiceInfo >
      64             : {
      65             : private:
      66             :     rtl::Reference<ScHeaderFooterTextObj> mxLeftText;
      67             :     rtl::Reference<ScHeaderFooterTextObj> mxCenterText;
      68             :     rtl::Reference<ScHeaderFooterTextObj> mxRightText;
      69             : 
      70             :     ScHeaderFooterContentObj(); // disabled
      71             : 
      72             : public:
      73             :     ScHeaderFooterContentObj( const EditTextObject* pLeft,
      74             :                               const EditTextObject* pCenter,
      75             :                               const EditTextObject* pRight );
      76             :     virtual                 ~ScHeaderFooterContentObj();
      77             : 
      78             :                             // for ScPageHFItem (using getImplementation)
      79             :     const EditTextObject* GetLeftEditObject() const;
      80             :     const EditTextObject* GetCenterEditObject() const;
      81             :     const EditTextObject* GetRightEditObject() const;
      82             : 
      83             :                             // XHeaderFooterContent
      84             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
      85             :                             getLeftText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      86             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
      87             :                             getCenterText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      88             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
      89             :                             getRightText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      90             : 
      91             :                             // XUnoTunnel
      92             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
      93             :                                     sal_Int8 >& aIdentifier )
      94             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      95             : 
      96             :     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
      97             :     static ScHeaderFooterContentObj* getImplementation( const com::sun::star::uno::Reference<
      98             :                                     com::sun::star::sheet::XHeaderFooterContent> xObj );
      99             : 
     100             :                             // XServiceInfo
     101             :     virtual OUString SAL_CALL getImplementationName()
     102             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     104             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
     106             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     107             : };
     108             : 
     109             : //  ScHeaderFooterTextData: shared data between sub objects of a ScHeaderFooterTextObj
     110             : 
     111             : class ScHeaderFooterTextData : boost::noncopyable
     112             : {
     113             : private:
     114             :     EditTextObject* mpTextObj;
     115             :     ScHeaderFooterContentObj&   rContentObj;
     116             :     sal_uInt16                      nPart;
     117             :     ScEditEngineDefaulter*      pEditEngine;
     118             :     SvxEditEngineForwarder*     pForwarder;
     119             :     bool                        bDataValid;
     120             : 
     121             : public:
     122             :     ScHeaderFooterTextData(
     123             :         ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
     124             :     ~ScHeaderFooterTextData();
     125             : 
     126             :                             // helper functions
     127             :     SvxTextForwarder*       GetTextForwarder();
     128             :     void UpdateData();
     129             :     void UpdateData(EditEngine& rEditEngine);
     130          74 :     ScEditEngineDefaulter*  GetEditEngine() { GetTextForwarder(); return pEditEngine; }
     131             : 
     132        3580 :     sal_uInt16                  GetPart() const         { return nPart; }
     133        3580 :     ScHeaderFooterContentObj& GetContentObj() const { return rContentObj; }
     134             : 
     135        9426 :     const EditTextObject* GetTextObject() const { return mpTextObj;}
     136             : };
     137             : 
     138             : /**
     139             :  * Each of these instances represent, the left, center or right part of the
     140             :  * header of footer of a page.
     141             :  *
     142             :  * ScHeaderFooterTextObj changes the text in a ScHeaderFooterContentObj.
     143             :  */
     144             : class ScHeaderFooterTextObj : public cppu::WeakImplHelper5<
     145             :                             com::sun::star::text::XText,
     146             :                             com::sun::star::text::XTextRangeMover,
     147             :                             com::sun::star::container::XEnumerationAccess,
     148             :                             com::sun::star::text::XTextFieldsSupplier,
     149             :                             com::sun::star::lang::XServiceInfo >
     150             : {
     151             : private:
     152             :     ScHeaderFooterTextData      aTextData;
     153             :     rtl::Reference<SvxUnoText> mxUnoText;
     154             : 
     155             :     void                    CreateUnoText_Impl();
     156             : 
     157             : public:
     158             :     ScHeaderFooterTextObj(
     159             :         ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
     160             :     virtual ~ScHeaderFooterTextObj();
     161             : 
     162             :     const EditTextObject* GetTextObject() const;
     163             :     const SvxUnoText&       GetUnoText();
     164             : 
     165             :     static void             FillDummyFieldData( ScHeaderFieldData& rData );
     166             : 
     167             :                             // XText
     168             :     virtual void SAL_CALL   insertTextContent( const ::com::sun::star::uno::Reference<
     169             :                                     ::com::sun::star::text::XTextRange >& xRange,
     170             :                                 const ::com::sun::star::uno::Reference<
     171             :                                     ::com::sun::star::text::XTextContent >& xContent,
     172             :                                 sal_Bool bAbsorb )
     173             :                                     throw(::com::sun::star::lang::IllegalArgumentException,
     174             :                                     ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     175             :     virtual void SAL_CALL   removeTextContent( const ::com::sun::star::uno::Reference<
     176             :                                 ::com::sun::star::text::XTextContent >& xContent )
     177             :                                     throw(::com::sun::star::container::NoSuchElementException,
     178             :                                             ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     179             : 
     180             :                             // XSimpleText
     181             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
     182             :                             createTextCursor() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     183             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
     184             :                             createTextCursorByRange( const ::com::sun::star::uno::Reference<
     185             :                                         ::com::sun::star::text::XTextRange >& aTextPosition )
     186             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     187             :     virtual void SAL_CALL   insertString( const ::com::sun::star::uno::Reference<
     188             :                                         ::com::sun::star::text::XTextRange >& xRange,
     189             :                                         const OUString& aString, sal_Bool bAbsorb )
     190             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     191             :     virtual void SAL_CALL   insertControlCharacter( const ::com::sun::star::uno::Reference<
     192             :                                         ::com::sun::star::text::XTextRange >& xRange,
     193             :                                         sal_Int16 nControlCharacter, sal_Bool bAbsorb )
     194             :                                     throw(::com::sun::star::lang::IllegalArgumentException,
     195             :                                         ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     196             : 
     197             :                             // XTextRange
     198             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
     199             :                             getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     201             :                             getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     202             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     203             :                             getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     204             :     virtual OUString SAL_CALL getString() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     205             :     virtual void SAL_CALL   setString( const OUString& aString )
     206             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     207             : 
     208             :                             // XTextRangeMover
     209             :     virtual void SAL_CALL   moveTextRange( const ::com::sun::star::uno::Reference<
     210             :                                         ::com::sun::star::text::XTextRange >& xRange,
     211             :                                         sal_Int16 nParagraphs )
     212             :                                     throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     213             : 
     214             :                             // XEnumerationAccess
     215             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
     216             :                             createEnumeration() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     217             : 
     218             :                             // XElementAccess
     219             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
     220             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     221             :     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     222             : 
     223             :                             // XTextFieldsSupplier
     224             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > SAL_CALL
     225             :                             getTextFields() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     226             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
     227             :                             getTextFieldMasters() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     228             : 
     229             :                             // XServiceInfo
     230             :     virtual OUString SAL_CALL getImplementationName()
     231             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     232             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     233             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     234             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
     235             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     236             : };
     237             : 
     238             : //  derived cursor objects for getImplementation and getText/getStart/getEnd
     239             : 
     240             : //! uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
     241             : 
     242             : class ScCellTextCursor : public SvxUnoTextCursor
     243             : {
     244             :     ScCellObj&              rTextObj;
     245             : 
     246             : public:
     247             :                             ScCellTextCursor(const ScCellTextCursor& rOther);
     248             :                             ScCellTextCursor(ScCellObj& rText);
     249             :         virtual                                 ~ScCellTextCursor() throw();
     250             : 
     251           0 :     ScCellObj&              GetCellObj() const  { return rTextObj; }
     252             : 
     253             :                             // SvxUnoTextCursor methods reimplemented here:
     254             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
     255             :                             getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     256             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     257             :                             getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     258             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     259             :                             getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     260             : 
     261             :                             // XUnoTunnel
     262             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
     263             :                                     sal_Int8 >& aIdentifier )
     264             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     265             : 
     266             :     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
     267             :     static ScCellTextCursor* getImplementation( const com::sun::star::uno::Reference<
     268             :                                     com::sun::star::uno::XInterface> xObj );
     269             : };
     270             : 
     271             : class ScHeaderFooterTextCursor : public SvxUnoTextCursor
     272             : {
     273             : private:
     274             :     ScHeaderFooterTextObj&  rTextObj;
     275             : 
     276             : public:
     277             :                             ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther);
     278             :                             ScHeaderFooterTextCursor(ScHeaderFooterTextObj& rText);
     279             :         virtual                                 ~ScHeaderFooterTextCursor() throw();
     280             : 
     281             :                             // SvxUnoTextCursor methods reimplemented here:
     282             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
     283             :                             getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     284             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     285             :                             getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     286             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     287             :                             getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     288             : 
     289             :                             // XUnoTunnel
     290             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
     291             :                                     sal_Int8 >& aIdentifier )
     292             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     293             : 
     294             :     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
     295             :     static ScHeaderFooterTextCursor* getImplementation( const com::sun::star::uno::Reference<
     296             :                                     com::sun::star::uno::XInterface> xObj );
     297             : };
     298             : 
     299             : class ScDrawTextCursor : public SvxUnoTextCursor
     300             : {
     301             : private:
     302             :     com::sun::star::uno::Reference< com::sun::star::text::XText > xParentText;
     303             : 
     304             : public:
     305             :                             ScDrawTextCursor(const ScDrawTextCursor& rOther);
     306             :                             ScDrawTextCursor( const com::sun::star::uno::Reference<
     307             :                                                 com::sun::star::text::XText >& xParent,
     308             :                                             const SvxUnoTextBase& rText );
     309             :     virtual                  ~ScDrawTextCursor() throw();
     310             : 
     311             :                             // SvxUnoTextCursor methods reimplemented here:
     312             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
     313             :                             getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     314             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     315             :                             getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     316             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
     317             :                             getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     318             : 
     319             :                             // XUnoTunnel
     320             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
     321             :                                     sal_Int8 >& aIdentifier )
     322             :                                 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     323             : 
     324             :     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
     325             :     static ScDrawTextCursor* getImplementation( const com::sun::star::uno::Reference<
     326             :                                     com::sun::star::uno::XInterface> xObj );
     327             : };
     328             : 
     329             : // ScAnnotationTextCursor isn't needed anymore - SvxUnoTextCursor is used instead
     330             : 
     331             : //  ScEditEngineTextObj for formatted cell content that is not inserted in a cell or header/footer
     332             : //  (used for XML export of change tracking contents)
     333             : 
     334             : class ScSimpleEditSourceHelper
     335             : {
     336             :     ScEditEngineDefaulter*  pEditEngine;
     337             :     SvxEditEngineForwarder* pForwarder;
     338             :     ScSimpleEditSource*     pOriginalSource;
     339             : 
     340             : public:
     341             :             ScSimpleEditSourceHelper();
     342             :             ~ScSimpleEditSourceHelper();
     343             : 
     344           0 :     ScSimpleEditSource* GetOriginalSource() const   { return pOriginalSource; }
     345           0 :     ScEditEngineDefaulter* GetEditEngine() const    { return pEditEngine; }
     346             : };
     347             : 
     348             : class ScEditEngineTextObj : public ScSimpleEditSourceHelper, public SvxUnoText
     349             : {
     350             : public:
     351             :                         ScEditEngineTextObj();
     352             :         virtual                         ~ScEditEngineTextObj() throw();
     353             : 
     354             :     void                SetText( const EditTextObject& rTextObject );
     355             :     EditTextObject*     CreateTextObject();
     356             : };
     357             : 
     358             : //  ScCellTextData: shared data between sub objects of a cell text object
     359             : 
     360             : class ScCellTextData : public SfxListener
     361             : {
     362             : protected:
     363             :     ScDocShell*             pDocShell;
     364             :     ScAddress               aCellPos;
     365             :     ScFieldEditEngine*      pEditEngine;
     366             :     SvxEditEngineForwarder* pForwarder;
     367             :     ScCellEditSource* pOriginalSource;
     368             :     bool                    bDataValid;
     369             :     bool                    bInUpdate;
     370             :     bool                    bDirty;
     371             :     bool                    bDoUpdate;
     372             : 
     373             : protected:
     374             :     virtual void            GetCellText(const ScAddress& rCellPos, OUString& rText);
     375             : 
     376             : public:
     377             :                             ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP);
     378             :     virtual                 ~ScCellTextData();
     379             : 
     380             :     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     381             : 
     382             :                             // helper functions for ScSharedCellEditSource:
     383             :     virtual SvxTextForwarder* GetTextForwarder();
     384             :     void                    UpdateData();
     385          98 :     ScFieldEditEngine*      GetEditEngine() { GetTextForwarder(); return pEditEngine; }
     386             : 
     387             :     ScCellEditSource* GetOriginalSource();        // used as argument for SvxUnoText ctor
     388             : 
     389             :                             // used for ScCellEditSource:
     390          58 :     ScDocShell*             GetDocShell() const     { return pDocShell; }
     391          58 :     const ScAddress&        GetCellPos() const      { return aCellPos; }
     392             : 
     393             :     void                    SetDirty(bool bValue)   { bDirty = bValue; }
     394           0 :     bool                    IsDirty() const         { return bDirty; }
     395           0 :     void                    SetDoUpdate(bool bValue)    { bDoUpdate = bValue; }
     396             : };
     397             : 
     398             : class ScCellTextObj : public ScCellTextData, public SvxUnoText
     399             : {
     400             : public:
     401             :                 ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP);
     402             :         virtual         ~ScCellTextObj() throw();
     403             : };
     404             : 
     405             : #endif
     406             : 
     407             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10