LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ChartController_TextEdit.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 85 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "ChartController.hxx"
      21             : 
      22             : #include "ResId.hxx"
      23             : #include "UndoGuard.hxx"
      24             : #include "DrawViewWrapper.hxx"
      25             : #include "ChartWindow.hxx"
      26             : #include "TitleHelper.hxx"
      27             : #include "ObjectIdentifier.hxx"
      28             : #include "macros.hxx"
      29             : #include "ControllerLockGuard.hxx"
      30             : #include "AccessibleTextHelper.hxx"
      31             : #include "Strings.hrc"
      32             : #include "chartview/DrawModelWrapper.hxx"
      33             : 
      34             : #include <svx/svdotext.hxx>
      35             : 
      36             : // header for define RET_OK
      37             : #include <vcl/msgbox.hxx>
      38             : // header for class SdrOutliner
      39             : #include <svx/svdoutl.hxx>
      40             : #include <svx/svxdlg.hxx>
      41             : #include <svx/dialogs.hrc>
      42             : #include <vcl/svapp.hxx>
      43             : #include <osl/mutex.hxx>
      44             : #include <com/sun/star/beans/XPropertySet.hpp>
      45             : #include <svl/stritem.hxx>
      46             : #include <editeng/fontitem.hxx>
      47             : 
      48             : namespace chart
      49             : {
      50             : using namespace ::com::sun::star;
      51             : 
      52           0 : void SAL_CALL ChartController::executeDispatch_EditText( const Point* pMousePixel )
      53             : {
      54           0 :     this->StartTextEdit( pMousePixel );
      55           0 : }
      56             : 
      57           0 : void ChartController::StartTextEdit( const Point* pMousePixel )
      58             : {
      59             :     //the first marked object will be edited
      60             : 
      61           0 :     SolarMutexGuard aGuard;
      62           0 :     SdrObject* pTextObj = m_pDrawViewWrapper->getTextEditObject();
      63           0 :     if(!pTextObj)
      64           0 :         return;
      65             : 
      66             :     OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" );
      67             :     m_pTextActionUndoGuard.reset( new UndoGuard(
      68           0 :         SCH_RESSTR( STR_ACTION_EDIT_TEXT ), m_xUndoManager ) );
      69           0 :     SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
      70             : 
      71             :     //#i77362 change notification for changes on additional shapes are missing
      72           0 :     uno::Reference< beans::XPropertySet > xChartViewProps( m_xChartView, uno::UNO_QUERY );
      73           0 :     if( xChartViewProps.is() )
      74           0 :         xChartViewProps->setPropertyValue( "SdrViewIsInEditMode", uno::makeAny(sal_True) );
      75             : 
      76             :     sal_Bool bEdit = m_pDrawViewWrapper->SdrBeginTextEdit( pTextObj
      77             :                     , m_pDrawViewWrapper->GetPageView()
      78             :                     , m_pChartWindow
      79             :                     , false //bIsNewObj
      80             :                     , pOutliner
      81             :                     , 0L //pOutlinerView
      82             :                     , true //bDontDeleteOutliner
      83             :                     , true //bOnlyOneView
      84           0 :                     );
      85           0 :     if(bEdit)
      86             :     {
      87           0 :         m_pDrawViewWrapper->SetEditMode();
      88             : 
      89             :         // #i12587# support for shapes in chart
      90           0 :         if ( pMousePixel )
      91             :         {
      92           0 :             OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
      93           0 :             if ( pOutlinerView )
      94             :             {
      95           0 :                 MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
      96           0 :                 pOutlinerView->MouseButtonDown( aEditEvt );
      97           0 :                 pOutlinerView->MouseButtonUp( aEditEvt );
      98             :             }
      99             :         }
     100             : 
     101             :         //we invalidate the outliner region because the outliner has some
     102             :         //paint problems (some characters are painted twice a little bit shifted)
     103           0 :         m_pChartWindow->Invalidate( m_pDrawViewWrapper->GetMarkedObjBoundRect() );
     104           0 :     }
     105             : }
     106             : 
     107           0 : bool ChartController::EndTextEdit()
     108             : {
     109           0 :     m_pDrawViewWrapper->SdrEndTextEdit();
     110             : 
     111             :     //#i77362 change notification for changes on additional shapes are missing
     112           0 :     uno::Reference< beans::XPropertySet > xChartViewProps( m_xChartView, uno::UNO_QUERY );
     113           0 :     if( xChartViewProps.is() )
     114           0 :         xChartViewProps->setPropertyValue( "SdrViewIsInEditMode", uno::makeAny(sal_False) );
     115             : 
     116           0 :     SdrObject* pTextObject = m_pDrawViewWrapper->getTextEditObject();
     117           0 :     if(!pTextObject)
     118           0 :         return false;
     119             : 
     120           0 :     SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
     121           0 :     OutlinerParaObject* pParaObj = pTextObject->GetOutlinerParaObject();
     122           0 :     if( pParaObj && pOutliner )
     123             :     {
     124           0 :         pOutliner->SetText( *pParaObj );
     125             : 
     126             :         OUString aString = pOutliner->GetText(
     127             :                             pOutliner->GetParagraph( 0 ),
     128           0 :                             pOutliner->GetParagraphCount() );
     129             : 
     130           0 :         OUString aObjectCID = m_aSelection.getSelectedCID();
     131           0 :         if ( !aObjectCID.isEmpty() )
     132             :         {
     133             :             uno::Reference< beans::XPropertySet > xPropSet =
     134           0 :                 ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() );
     135             : 
     136             :             // lock controllers till end of block
     137           0 :             ControllerLockGuardUNO aCLGuard( getModel() );
     138             : 
     139             :             TitleHelper::setCompleteString( aString, uno::Reference<
     140           0 :                 ::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC );
     141             : 
     142             :             OSL_ENSURE( m_pTextActionUndoGuard.get(), "ChartController::EndTextEdit: no TextUndoGuard!" );
     143           0 :             if ( m_pTextActionUndoGuard.get() )
     144           0 :                 m_pTextActionUndoGuard->commit();
     145             :         }
     146           0 :         m_pTextActionUndoGuard.reset();
     147             :     }
     148           0 :     return true;
     149             : }
     150             : 
     151           0 : void SAL_CALL ChartController::executeDispatch_InsertSpecialCharacter()
     152             : {
     153           0 :     SolarMutexGuard aGuard;
     154           0 :     if( !m_pDrawViewWrapper)
     155             :     {
     156             :         OSL_ENSURE( m_pDrawViewWrapper, "No DrawViewWrapper for ChartController" );
     157           0 :         return;
     158             :     }
     159           0 :     if( !m_pDrawViewWrapper->IsTextEdit() )
     160           0 :         this->StartTextEdit();
     161             : 
     162           0 :     SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create();
     163             :     OSL_ENSURE( pFact, "No dialog factory" );
     164             : 
     165           0 :     SfxAllItemSet aSet( m_pDrawModelWrapper->GetItemPool() );
     166           0 :     aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
     167             : 
     168             :     //set fixed current font
     169           0 :     aSet.Put( SfxBoolItem( FN_PARAM_2, true ) ); //maybe not necessary in future
     170             : 
     171           0 :     Font aCurFont = m_pDrawViewWrapper->getOutliner()->GetRefDevice()->GetFont();
     172           0 :     aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), SID_ATTR_CHAR_FONT ) );
     173             : 
     174           0 :     SfxAbstractDialog * pDlg = pFact->CreateSfxDialog( m_pChartWindow, aSet, getFrame(), RID_SVXDLG_CHARMAP );
     175             :     OSL_ENSURE( pDlg, "Couldn't create SvxCharacterMap dialog" );
     176           0 :     if( pDlg->Execute() == RET_OK )
     177             :     {
     178           0 :         const SfxItemSet* pSet = pDlg->GetOutputItemSet();
     179           0 :         const SfxPoolItem* pItem=0;
     180           0 :         OUString aString;
     181           0 :         if ( pSet && pSet->GetItemState( SID_CHARMAP, true, &pItem) == SFX_ITEM_SET &&
     182           0 :              pItem->ISA(SfxStringItem) )
     183           0 :                 aString = dynamic_cast<const SfxStringItem*>(pItem)->GetValue();
     184             : 
     185           0 :         OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
     186           0 :         SdrOutliner*  pOutliner = m_pDrawViewWrapper->getOutliner();
     187             : 
     188           0 :         if(!pOutliner || !pOutlinerView)
     189           0 :             return;
     190             : 
     191             :         // insert string to outliner
     192             : 
     193             :         // prevent flicker
     194           0 :         pOutlinerView->HideCursor();
     195           0 :         pOutliner->SetUpdateMode(false);
     196             : 
     197             :         // delete current selection by inserting empty String, so current
     198             :         // attributes become unique (sel. has to be erased anyway)
     199           0 :         pOutlinerView->InsertText(OUString());
     200             : 
     201           0 :         pOutlinerView->InsertText(aString, true);
     202             : 
     203           0 :         ESelection aSel = pOutlinerView->GetSelection();
     204           0 :         aSel.nStartPara = aSel.nEndPara;
     205           0 :         aSel.nStartPos = aSel.nEndPos;
     206           0 :         pOutlinerView->SetSelection(aSel);
     207             : 
     208             :         // show changes
     209           0 :         pOutliner->SetUpdateMode(true);
     210           0 :         pOutlinerView->ShowCursor();
     211             :     }
     212             : 
     213           0 :     delete pDlg;
     214             : }
     215             : 
     216             : uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     217           0 :     ChartController::impl_createAccessibleTextContext()
     218             : {
     219             :     uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xResult(
     220           0 :         new AccessibleTextHelper( m_pDrawViewWrapper ));
     221             : 
     222           0 :     return xResult;
     223             : }
     224             : 
     225           0 : } //namespace chart
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10