LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - notesuno.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 101 0.0 %
Date: 2014-04-14 Functions: 0 28 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             : #include "notesuno.hxx"
      21             : 
      22             : #include <vcl/svapp.hxx>
      23             : #include <svl/smplhint.hxx>
      24             : #include <editeng/unotext.hxx>
      25             : #include <editeng/unoprnms.hxx>
      26             : #include <svx/svdpool.hxx>
      27             : #include <svx/svdobj.hxx>
      28             : #include <svx/unoshape.hxx>
      29             : #include <svx/svdocapt.hxx>
      30             : 
      31             : #include "postit.hxx"
      32             : #include "cellsuno.hxx"
      33             : #include "docsh.hxx"
      34             : #include "docfunc.hxx"
      35             : #include "hints.hxx"
      36             : #include "editsrc.hxx"
      37             : #include "miscuno.hxx"
      38             : 
      39             : using namespace com::sun::star;
      40             : 
      41           0 : static const SvxItemPropertySet* lcl_GetAnnotationPropertySet()
      42             : {
      43             :     static const SfxItemPropertyMapEntry aAnnotationPropertyMap_Impl[] =
      44             :     {
      45           0 :         SVX_UNOEDIT_CHAR_PROPERTIES,
      46           0 :         SVX_UNOEDIT_FONT_PROPERTIES,
      47           0 :         SVX_UNOEDIT_PARA_PROPERTIES,
      48           0 :         SVX_UNOEDIT_NUMBERING_PROPERTIE,    // for completeness of service ParagraphProperties
      49             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      50           0 :     };
      51           0 :     static SvxItemPropertySet aAnnotationPropertySet_Impl( aAnnotationPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
      52           0 :     return &aAnnotationPropertySet_Impl;
      53             : }
      54             : 
      55           0 : SC_SIMPLE_SERVICE_INFO( ScAnnotationObj, "ScAnnotationObj", "com.sun.star.sheet.CellAnnotation" )
      56             : //SC_SIMPLE_SERVICE_INFO( ScAnnotationShapeObj, "ScAnnotationShapeObj", "com.sun.star.sheet.CellAnnotationShape" )
      57             : 
      58           0 : ScAnnotationObj::ScAnnotationObj(ScDocShell* pDocSh, const ScAddress& rPos) :
      59             :     pDocShell( pDocSh ),
      60             :     aCellPos( rPos ),
      61           0 :     pUnoText( NULL )
      62             : {
      63           0 :     pDocShell->GetDocument()->AddUnoObject(*this);
      64             : 
      65             :     //  pUnoText is allocated on demand (GetUnoText)
      66             :     //  can't be aggregated because getString/setString is handled here
      67           0 : }
      68             : 
      69           0 : ScAnnotationObj::~ScAnnotationObj()
      70             : {
      71           0 :     if (pDocShell)
      72           0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
      73             : 
      74           0 :     if (pUnoText)
      75           0 :         pUnoText->release();
      76           0 : }
      77             : 
      78           0 : void ScAnnotationObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
      79             : {
      80           0 :     if ( rHint.ISA( ScUpdateRefHint ) )
      81             :     {
      82             : //        const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
      83             : 
      84             :         //! Ref-Update
      85             :     }
      86           0 :     else if ( rHint.ISA( SfxSimpleHint ) &&
      87           0 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
      88             :     {
      89           0 :         pDocShell = NULL;       // ungueltig geworden
      90             :     }
      91           0 : }
      92             : 
      93             : 
      94             : // XChild
      95             : 
      96           0 : uno::Reference<uno::XInterface> SAL_CALL ScAnnotationObj::getParent() throw(uno::RuntimeException, std::exception)
      97             : {
      98           0 :     SolarMutexGuard aGuard;
      99             : 
     100             :     //  Parent der Notiz ist die zugehoerige Zelle
     101             :     //! existierendes Objekt finden und zurueckgeben ???
     102             : 
     103           0 :     if (pDocShell)
     104           0 :         return (cppu::OWeakObject*)new ScCellObj( pDocShell, aCellPos );
     105             : 
     106           0 :     return NULL;
     107             : }
     108             : 
     109           0 : void SAL_CALL ScAnnotationObj::setParent( const uno::Reference<uno::XInterface>& /* Parent */ )
     110             :                                     throw(lang::NoSupportException, uno::RuntimeException, std::exception)
     111             : {
     112             :     //  hamma nich
     113             :     //! Exception oder so ??!
     114           0 : }
     115             : 
     116             : // XSimpleText
     117             : 
     118           0 : uno::Reference<text::XTextCursor> SAL_CALL ScAnnotationObj::createTextCursor()
     119             :                                                     throw(uno::RuntimeException, std::exception)
     120             : {
     121           0 :     SolarMutexGuard aGuard;
     122             :     //  Notizen brauchen keine Extrawurst
     123           0 :     return GetUnoText().createTextCursor();
     124             : }
     125             : 
     126           0 : uno::Reference<text::XTextCursor> SAL_CALL ScAnnotationObj::createTextCursorByRange(
     127             :                                     const uno::Reference<text::XTextRange>& aTextPosition )
     128             :                                                     throw(uno::RuntimeException, std::exception)
     129             : {
     130           0 :     SolarMutexGuard aGuard;
     131             :     //  Notizen brauchen keine Extrawurst
     132           0 :     return GetUnoText().createTextCursorByRange(aTextPosition);
     133             : }
     134             : 
     135           0 : OUString SAL_CALL ScAnnotationObj::getString() throw(uno::RuntimeException, std::exception)
     136             : {
     137           0 :     SolarMutexGuard aGuard;
     138           0 :     return GetUnoText().getString();
     139             : }
     140             : 
     141           0 : void SAL_CALL ScAnnotationObj::setString( const OUString& aText ) throw(uno::RuntimeException, std::exception)
     142             : {
     143           0 :     SolarMutexGuard aGuard;
     144           0 :     GetUnoText().setString(aText);
     145           0 : }
     146             : 
     147           0 : void SAL_CALL ScAnnotationObj::insertString( const uno::Reference<text::XTextRange>& xRange,
     148             :                                             const OUString& aString, sal_Bool bAbsorb )
     149             :                                 throw(uno::RuntimeException, std::exception)
     150             : {
     151           0 :     SolarMutexGuard aGuard;
     152           0 :     GetUnoText().insertString( xRange, aString, bAbsorb );
     153           0 : }
     154             : 
     155           0 : void SAL_CALL ScAnnotationObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
     156             :                                             sal_Int16 nControlCharacter, sal_Bool bAbsorb )
     157             :                                 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     158             : {
     159           0 :     SolarMutexGuard aGuard;
     160           0 :     GetUnoText().insertControlCharacter( xRange, nControlCharacter, bAbsorb );
     161           0 : }
     162             : 
     163           0 : uno::Reference<text::XText> SAL_CALL ScAnnotationObj::getText() throw(uno::RuntimeException, std::exception)
     164             : {
     165           0 :     SolarMutexGuard aGuard;
     166           0 :     return GetUnoText().getText();
     167             : }
     168             : 
     169           0 : uno::Reference<text::XTextRange> SAL_CALL ScAnnotationObj::getStart() throw(uno::RuntimeException, std::exception)
     170             : {
     171           0 :     SolarMutexGuard aGuard;
     172           0 :     return GetUnoText().getStart();
     173             : }
     174             : 
     175           0 : uno::Reference<text::XTextRange> SAL_CALL ScAnnotationObj::getEnd() throw(uno::RuntimeException, std::exception)
     176             : {
     177           0 :     SolarMutexGuard aGuard;
     178           0 :     return GetUnoText().getEnd();
     179             : }
     180             : 
     181             : // XSheetAnnotation
     182             : 
     183           0 : table::CellAddress SAL_CALL ScAnnotationObj::getPosition() throw(uno::RuntimeException, std::exception)
     184             : {
     185           0 :     SolarMutexGuard aGuard;
     186           0 :     table::CellAddress aAdr;
     187           0 :     aAdr.Sheet  = aCellPos.Tab();
     188           0 :     aAdr.Column = aCellPos.Col();
     189           0 :     aAdr.Row    = aCellPos.Row();
     190           0 :     return aAdr;
     191             : }
     192             : 
     193           0 : OUString SAL_CALL ScAnnotationObj::getAuthor()
     194             :     throw(uno::RuntimeException, std::exception)
     195             : {
     196           0 :     SolarMutexGuard aGuard;
     197           0 :     const ScPostIt* pNote = ImplGetNote();
     198           0 :     return pNote ? pNote->GetAuthor() : OUString();
     199             : }
     200             : 
     201           0 : OUString SAL_CALL ScAnnotationObj::getDate()
     202             :     throw(uno::RuntimeException, std::exception)
     203             : {
     204           0 :     SolarMutexGuard aGuard;
     205           0 :     const ScPostIt* pNote = ImplGetNote();
     206           0 :     return pNote ? pNote->GetDate() : OUString();
     207             : }
     208             : 
     209           0 : sal_Bool SAL_CALL ScAnnotationObj::getIsVisible() throw(uno::RuntimeException, std::exception)
     210             : {
     211           0 :     SolarMutexGuard aGuard;
     212           0 :     const ScPostIt* pNote = ImplGetNote();
     213           0 :     return pNote && pNote->IsCaptionShown();
     214             : }
     215             : 
     216           0 : void SAL_CALL ScAnnotationObj::setIsVisible( sal_Bool bIsVisible ) throw(uno::RuntimeException, std::exception)
     217             : {
     218           0 :     SolarMutexGuard aGuard;
     219             :     // show/hide note with undo action
     220           0 :     if( pDocShell )
     221           0 :         pDocShell->GetDocFunc().ShowNote( aCellPos, bIsVisible );
     222           0 : }
     223             : 
     224             : // XSheetAnnotationShapeSupplier
     225           0 : uno::Reference < drawing::XShape > SAL_CALL ScAnnotationObj::getAnnotationShape()
     226             :                                 throw(::com::sun::star::uno::RuntimeException,
     227             :                                       std::exception)
     228             : {
     229           0 :     SolarMutexGuard aGuard;
     230           0 :     uno::Reference < drawing::XShape > xShape;
     231           0 :     if( const ScPostIt* pNote = ImplGetNote() )
     232           0 :         if( SdrObject* pCaption = pNote->GetOrCreateCaption( aCellPos ) )
     233           0 :             xShape.set( pCaption->getUnoShape(), uno::UNO_QUERY );
     234           0 :     return xShape;
     235             : }
     236             : 
     237           0 : SvxUnoText& ScAnnotationObj::GetUnoText()
     238             : {
     239           0 :     if (!pUnoText)
     240             :     {
     241           0 :         ScAnnotationEditSource aEditSource( pDocShell, aCellPos );
     242             :         pUnoText = new SvxUnoText( &aEditSource, lcl_GetAnnotationPropertySet(),
     243           0 :                                     uno::Reference<text::XText>() );
     244           0 :         pUnoText->acquire();
     245             :     }
     246           0 :     return *pUnoText;
     247             : }
     248             : 
     249           0 : const ScPostIt* ScAnnotationObj::ImplGetNote() const
     250             : {
     251           0 :     return pDocShell ? pDocShell->GetDocument()->GetNote(aCellPos) : 0;
     252             : }
     253             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10