LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - editsrc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 97 116 83.6 %
Date: 2012-08-25 Functions: 31 39 79.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 67 122 54.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "editsrc.hxx"
      31                 :            : 
      32                 :            : #include "scitems.hxx"
      33                 :            : #include <editeng/eeitem.hxx>
      34                 :            : #include <editeng/unofored.hxx>
      35                 :            : #include <vcl/svapp.hxx>
      36                 :            : #include <svx/svdpage.hxx>
      37                 :            : #include <svx/svditer.hxx>
      38                 :            : #include <svx/svdocapt.hxx>
      39                 :            : #include <editeng/outlobj.hxx>
      40                 :            : #include <editeng/editobj.hxx>
      41                 :            : #include <editeng/outliner.hxx>
      42                 :            : #include "textuno.hxx"
      43                 :            : #include "editutil.hxx"
      44                 :            : #include "docsh.hxx"
      45                 :            : #include "docfunc.hxx"
      46                 :            : #include "hints.hxx"
      47                 :            : #include "patattr.hxx"
      48                 :            : #include "drwlayer.hxx"
      49                 :            : #include "userdat.hxx"
      50                 :            : #include "postit.hxx"
      51                 :            : #include "AccessibleText.hxx"
      52                 :            : 
      53                 :       5913 : ScHeaderFooterEditSource::ScHeaderFooterEditSource(ScHeaderFooterTextData& rData) :
      54                 :       5913 :     mrTextData(rData) {}
      55                 :            : 
      56         [ -  + ]:      10905 : ScHeaderFooterEditSource::~ScHeaderFooterEditSource() {}
      57                 :            : 
      58                 :         73 : ScEditEngineDefaulter* ScHeaderFooterEditSource::GetEditEngine()
      59                 :            : {
      60                 :         73 :     return mrTextData.GetEditEngine();
      61                 :            : }
      62                 :            : 
      63                 :       4117 : SvxEditSource* ScHeaderFooterEditSource::Clone() const
      64                 :            : {
      65         [ +  - ]:       4117 :     return new ScHeaderFooterEditSource(mrTextData);
      66                 :            : }
      67                 :            : 
      68                 :      36808 : SvxTextForwarder* ScHeaderFooterEditSource::GetTextForwarder()
      69                 :            : {
      70                 :      36808 :     return mrTextData.GetTextForwarder();
      71                 :            : }
      72                 :            : 
      73                 :       3305 : void ScHeaderFooterEditSource::UpdateData()
      74                 :            : {
      75                 :       3305 :     mrTextData.UpdateData();
      76                 :       3305 : }
      77                 :            : 
      78                 :            : //------------------------------------------------------------------------
      79                 :            : 
      80                 :        101 : ScCellEditSource::ScCellEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
      81 [ +  - ][ +  - ]:        101 :     pCellTextData(new ScCellTextData(pDocSh, rP)) {}
      82                 :            : 
      83                 :        101 : ScCellEditSource::~ScCellEditSource()
      84                 :            : {
      85 [ +  - ][ +  - ]:        101 :     delete pCellTextData;
      86         [ -  + ]:        202 : }
      87                 :            : 
      88                 :         69 : SvxEditSource* ScCellEditSource::Clone() const
      89                 :            : {
      90         [ +  - ]:         69 :     return new ScCellEditSource(pCellTextData->GetDocShell(), pCellTextData->GetCellPos());
      91                 :            : }
      92                 :            : 
      93                 :       1913 : SvxTextForwarder* ScCellEditSource::GetTextForwarder()
      94                 :            : {
      95                 :       1913 :     return pCellTextData->GetTextForwarder();
      96                 :            : }
      97                 :            : 
      98                 :        262 : void ScCellEditSource::UpdateData()
      99                 :            : {
     100                 :        262 :     pCellTextData->UpdateData();
     101                 :        262 : }
     102                 :            : 
     103                 :          6 : void ScCellEditSource::SetDoUpdateData(bool bValue)
     104                 :            : {
     105                 :          6 :     pCellTextData->SetDoUpdate(bValue);
     106                 :          6 : }
     107                 :            : 
     108                 :          0 : bool ScCellEditSource::IsDirty() const
     109                 :            : {
     110                 :          0 :     return pCellTextData->IsDirty();
     111                 :            : }
     112                 :            : 
     113                 :         90 : ScEditEngineDefaulter* ScCellEditSource::GetEditEngine()
     114                 :            : {
     115                 :         90 :     return pCellTextData->GetEditEngine();
     116                 :            : }
     117                 :            : 
     118                 :            : //------------------------------------------------------------------------
     119                 :            : 
     120                 :         23 : ScAnnotationEditSource::ScAnnotationEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
     121                 :            :     pDocShell( pDocSh ),
     122                 :            :     aCellPos( rP ),
     123                 :            :     pEditEngine( NULL ),
     124                 :            :     pForwarder( NULL ),
     125         [ +  - ]:         23 :     bDataValid( false )
     126                 :            : {
     127         [ +  - ]:         23 :     if (pDocShell)
     128         [ +  - ]:         23 :         pDocShell->GetDocument()->AddUnoObject(*this);
     129                 :         23 : }
     130                 :            : 
     131         [ +  - ]:         23 : ScAnnotationEditSource::~ScAnnotationEditSource()
     132                 :            : {
     133         [ +  - ]:         23 :     SolarMutexGuard aGuard;     //  needed for EditEngine dtor
     134                 :            : 
     135         [ +  + ]:         23 :     if (pDocShell)
     136         [ +  - ]:         19 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
     137                 :            : 
     138 [ +  + ][ +  - ]:         23 :     delete pForwarder;
     139 [ +  + ][ +  - ]:         23 :     delete pEditEngine;
                 [ +  - ]
     140         [ -  + ]:         36 : }
     141                 :            : 
     142                 :         13 : SvxEditSource* ScAnnotationEditSource::Clone() const
     143                 :            : {
     144         [ +  - ]:         13 :     return new ScAnnotationEditSource( pDocShell, aCellPos );
     145                 :            : }
     146                 :            : 
     147                 :         10 : SdrObject* ScAnnotationEditSource::GetCaptionObj()
     148                 :            : {
     149                 :         10 :     ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos);
     150         [ +  + ]:         10 :     return pNote ? pNote->GetOrCreateCaption( aCellPos ) : 0;
     151                 :            : }
     152                 :            : 
     153                 :         75 : SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
     154                 :            : {
     155         [ +  + ]:         75 :     if (!pEditEngine)
     156                 :            :     {
     157                 :            :         // Notizen haben keine Felder
     158         [ +  - ]:         13 :         if ( pDocShell )
     159                 :            :         {
     160         [ +  - ]:         13 :             pEditEngine = new ScNoteEditEngine( pDocShell->GetDocument()->GetNoteEngine() );
     161                 :            :         }
     162                 :            :         else
     163                 :            :         {
     164                 :          0 :             SfxItemPool* pEnginePool = EditEngine::CreatePool();
     165                 :          0 :             pEnginePool->FreezeIdRanges();
     166         [ #  # ]:          0 :             pEditEngine = new ScEditEngineDefaulter( pEnginePool, sal_True );
     167                 :            :         }
     168         [ +  - ]:         13 :         pForwarder = new SvxEditEngineForwarder(*pEditEngine);
     169                 :            :     }
     170                 :            : 
     171         [ +  + ]:         75 :     if (bDataValid)
     172                 :         51 :         return pForwarder;
     173                 :            : 
     174         [ +  - ]:         24 :     if ( pDocShell )
     175         [ +  + ]:         24 :         if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( aCellPos.Tab() )->findByAddress(aCellPos) )
     176         [ +  - ]:          6 :             if ( const EditTextObject* pEditObj = pNote->GetEditTextObject() )
     177                 :          6 :                 pEditEngine->SetText( *pEditObj );      // incl. Umbrueche
     178                 :            : 
     179                 :         24 :     bDataValid = sal_True;
     180                 :         75 :     return pForwarder;
     181                 :            : }
     182                 :            : 
     183                 :         10 : void ScAnnotationEditSource::UpdateData()
     184                 :            : {
     185 [ +  - ][ +  - ]:         10 :     if ( pDocShell && pEditEngine )
     186                 :            :     {
     187         [ +  - ]:         10 :         ScDocShellModificator aModificator( *pDocShell );
     188                 :            : 
     189 [ +  - ][ +  + ]:         10 :         if( SdrObject* pObj = GetCaptionObj() )
     190                 :            :         {
     191         [ +  - ]:          3 :             EditTextObject* pEditObj = pEditEngine->CreateTextObject();
     192 [ +  - ][ +  - ]:          3 :             OutlinerParaObject* pOPO = new OutlinerParaObject( *pEditObj );
                 [ +  - ]
     193 [ +  - ][ +  - ]:          3 :             delete pEditObj;
     194         [ +  - ]:          3 :             pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT );
     195         [ +  - ]:          3 :             pObj->NbcSetOutlinerParaObject( pOPO );
     196         [ +  - ]:          3 :             pObj->ActionChanged();
     197                 :            :         }
     198                 :            : 
     199                 :            :         //! Undo !!!
     200                 :            : 
     201 [ +  - ][ +  - ]:         10 :         aModificator.SetDocumentModified();
     202                 :            : 
     203                 :            :         // bDataValid wird bei SetDocumentModified zurueckgesetzt
     204                 :            :     }
     205                 :         10 : }
     206                 :            : 
     207                 :         21 : void ScAnnotationEditSource::Notify( SfxBroadcaster&, const SfxHint& rHint )
     208                 :            : {
     209         [ +  - ]:         21 :     if ( rHint.ISA( ScUpdateRefHint ) )
     210                 :            :     {
     211                 :            :         //! Ref-Update
     212                 :            :     }
     213         [ +  - ]:         21 :     else if ( rHint.ISA( SfxSimpleHint ) )
     214                 :            :     {
     215                 :         21 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
     216         [ +  + ]:         21 :         if ( nId == SFX_HINT_DYING )
     217                 :            :         {
     218                 :          4 :             pDocShell = NULL;                       // ungueltig geworden
     219                 :            : 
     220         [ +  - ]:          4 :             DELETEZ( pForwarder );
     221         [ +  - ]:          4 :             DELETEZ( pEditEngine );     // EditEngine uses document's pool
     222                 :            :         }
     223         [ +  - ]:         17 :         else if ( nId == SFX_HINT_DATACHANGED )
     224                 :         17 :             bDataValid = false;                     // Text muss neu geholt werden
     225                 :            :     }
     226                 :         21 : }
     227                 :            : 
     228                 :            : //------------------------------------------------------------------------
     229                 :            : 
     230                 :          0 : ScSimpleEditSource::ScSimpleEditSource( SvxTextForwarder* pForw ) :
     231                 :          0 :     pForwarder( pForw )
     232                 :            : {
     233                 :            :     //  The same forwarder (and EditEngine) is shared by all children of the same Text object.
     234                 :            :     //  Text range and cursor keep a reference to their parent text, so the text object is
     235                 :            :     //  always alive and the forwarder is valid as long as there are children.
     236                 :          0 : }
     237                 :            : 
     238                 :          0 : ScSimpleEditSource::~ScSimpleEditSource()
     239                 :            : {
     240         [ #  # ]:          0 : }
     241                 :            : 
     242                 :          0 : SvxEditSource* ScSimpleEditSource::Clone() const
     243                 :            : {
     244         [ #  # ]:          0 :     return new ScSimpleEditSource( pForwarder );
     245                 :            : }
     246                 :            : 
     247                 :          0 : SvxTextForwarder* ScSimpleEditSource::GetTextForwarder()
     248                 :            : {
     249                 :          0 :     return pForwarder;
     250                 :            : }
     251                 :            : 
     252                 :          0 : void ScSimpleEditSource::UpdateData()
     253                 :            : {
     254                 :            :     //  nothing
     255                 :          0 : }
     256                 :            : 
     257                 :            : //------------------------------------------------------------------------
     258                 :            : 
     259                 :            : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     260                 :         59 : ScAccessibilityEditSource::ScAccessibilityEditSource( ::std::auto_ptr < ScAccessibleTextData > pAccessibleCellTextData )
     261                 :         59 :     : mpAccessibleTextData(pAccessibleCellTextData)
     262                 :            : {
     263                 :         59 : }
     264                 :            : SAL_WNODEPRECATED_DECLARATIONS_POP
     265                 :            : 
     266         [ +  - ]:         48 : ScAccessibilityEditSource::~ScAccessibilityEditSource()
     267                 :            : {
     268         [ -  + ]:         96 : }
     269                 :            : 
     270                 :            : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     271                 :          4 : SvxEditSource* ScAccessibilityEditSource::Clone() const
     272                 :            : {
     273 [ +  - ][ +  - ]:          4 :     return new ScAccessibilityEditSource(::std::auto_ptr < ScAccessibleTextData > (mpAccessibleTextData->Clone()));
                 [ +  - ]
     274                 :            : }
     275                 :            : SAL_WNODEPRECATED_DECLARATIONS_POP
     276                 :            : 
     277                 :        835 : SvxTextForwarder* ScAccessibilityEditSource::GetTextForwarder()
     278                 :            : {
     279                 :        835 :     return mpAccessibleTextData->GetTextForwarder();
     280                 :            : }
     281                 :            : 
     282                 :        229 : SvxViewForwarder* ScAccessibilityEditSource::GetViewForwarder()
     283                 :            : {
     284                 :        229 :     return mpAccessibleTextData->GetViewForwarder();
     285                 :            : }
     286                 :            : 
     287                 :         81 : SvxEditViewForwarder* ScAccessibilityEditSource::GetEditViewForwarder( sal_Bool bCreate )
     288                 :            : {
     289                 :         81 :     return mpAccessibleTextData->GetEditViewForwarder(bCreate);
     290                 :            : }
     291                 :            : 
     292                 :          0 : void ScAccessibilityEditSource::UpdateData()
     293                 :            : {
     294                 :          0 :     mpAccessibleTextData->UpdateData();
     295                 :          0 : }
     296                 :            : 
     297                 :         77 : SfxBroadcaster& ScAccessibilityEditSource::GetBroadcaster() const
     298                 :            : {
     299                 :         77 :     return mpAccessibleTextData->GetBroadcaster();
     300                 :            : }
     301                 :            : 
     302                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10