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

Generated by: LCOV version 1.10