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

Generated by: LCOV version 1.10