LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuparagr.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 52 1.9 %
Date: 2015-06-13 12:38:46 Functions: 2 12 16.7 %
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 "fuparagr.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <sfx2/bindings.hxx>
      24             : #include <sfx2/request.hxx>
      25             : #include <sfx2/viewfrm.hxx>
      26             : #include <svx/svxids.hrc>
      27             : #include <editeng/editdata.hxx>
      28             : #include <editeng/lrspitem.hxx>
      29             : #include <svx/svdoutl.hxx>
      30             : 
      31             : #include "app.hrc"
      32             : #include "View.hxx"
      33             : #include "ViewShell.hxx"
      34             : #include "drawdoc.hxx"
      35             : #include "sdabstdlg.hxx"
      36             : #include "sdattr.hrc"
      37             : #include <boost/scoped_ptr.hpp>
      38             : 
      39             : namespace sd {
      40             : 
      41           0 : TYPEINIT1( FuParagraph, FuPoor );
      42             : 
      43           0 : FuParagraph::FuParagraph (
      44             :     ViewShell* pViewSh,
      45             :     ::sd::Window* pWin,
      46             :     ::sd::View* pView,
      47             :     SdDrawDocument* pDoc,
      48             :     SfxRequest& rReq)
      49           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      50             : {
      51           0 : }
      52             : 
      53           0 : rtl::Reference<FuPoor> FuParagraph::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      54             : {
      55           0 :     rtl::Reference<FuPoor> xFunc( new FuParagraph( pViewSh, pWin, pView, pDoc, rReq ) );
      56           0 :     xFunc->DoExecute(rReq);
      57           0 :     return xFunc;
      58             : }
      59             : 
      60           0 : void FuParagraph::DoExecute( SfxRequest& rReq )
      61             : {
      62           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      63             : 
      64           0 :     OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
      65           0 :     ::Outliner* pOutliner = mpView->GetTextEditOutliner();
      66             : 
      67           0 :     if( !pArgs )
      68             :     {
      69           0 :         SfxItemSet aEditAttr( mpDoc->GetPool() );
      70           0 :         mpView->GetAttributes( aEditAttr );
      71           0 :         SfxItemPool *pPool =  aEditAttr.GetPool();
      72             :         SfxItemSet aNewAttr( *pPool,
      73             :                              EE_ITEMS_START, EE_ITEMS_END,
      74             :                              SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
      75             :                              ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
      76           0 :                              0 );
      77             : 
      78           0 :         aNewAttr.Put( aEditAttr );
      79             : 
      80             :         // left border is offset
      81           0 :         const long nOff = static_cast<const SvxLRSpaceItem&>(aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTextLeft();
      82             :         // conversion since TabulatorTabPage always uses Twips!
      83           0 :         SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
      84           0 :         aNewAttr.Put( aOff );
      85             : 
      86           0 :         if( pOutlView && pOutliner )
      87             :         {
      88           0 :             ESelection eSelection = pOutlView->GetSelection();
      89           0 :             aNewAttr.Put( SfxInt16Item( ATTR_NUMBER_NEWSTART_AT, pOutliner->GetNumberingStartValue( eSelection.nStartPara ) ) );
      90           0 :             aNewAttr.Put( SfxBoolItem( ATTR_NUMBER_NEWSTART, pOutliner->IsParaIsNumberingRestart( eSelection.nStartPara ) ) );
      91             :         }
      92             : 
      93           0 :         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
      94           0 :         boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0);
      95           0 :         if (!pDlg)
      96           0 :             return;
      97             : 
      98           0 :         sal_uInt16 nResult = pDlg->Execute();
      99             : 
     100           0 :         switch( nResult )
     101             :         {
     102             :             case RET_OK:
     103             :             {
     104           0 :                 rReq.Done( *( pDlg->GetOutputItemSet() ) );
     105             : 
     106           0 :                 pArgs = rReq.GetArgs();
     107             :             }
     108           0 :             break;
     109             : 
     110             :             default:
     111           0 :             return; // Cancel
     112           0 :         }
     113             :     }
     114           0 :     mpView->SetAttributes( *pArgs );
     115             : 
     116           0 :     if( pOutlView && pOutliner )
     117             :     {
     118           0 :         ESelection eSelection = pOutlView->GetSelection();
     119             : 
     120           0 :         const SfxPoolItem *pItem = 0;
     121           0 :         if( SfxItemState::SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART, false, &pItem ) )
     122             :         {
     123           0 :             const bool bNewStart = static_cast<const SfxBoolItem*>(pItem)->GetValue();
     124           0 :             pOutliner->SetParaIsNumberingRestart( eSelection.nStartPara, bNewStart );
     125             :         }
     126             : 
     127           0 :         if( SfxItemState::SET == pArgs->GetItemState( ATTR_NUMBER_NEWSTART_AT, false, &pItem ) )
     128             :         {
     129           0 :             const sal_Int16 nStartAt = static_cast<const SfxInt16Item*>(pItem)->GetValue();
     130           0 :             pOutliner->SetNumberingStartValue( eSelection.nStartPara, nStartAt );
     131             :         }
     132             :     }
     133             : 
     134             :     // invalidate slots
     135             :     static sal_uInt16 SidArray[] = {
     136             :         SID_ATTR_TABSTOP,
     137             :         SID_ATTR_PARA_ADJUST_LEFT,
     138             :         SID_ATTR_PARA_ADJUST_RIGHT,
     139             :         SID_ATTR_PARA_ADJUST_CENTER,
     140             :         SID_ATTR_PARA_ADJUST_BLOCK,
     141             :         SID_ATTR_PARA_LINESPACE,
     142             :         SID_ATTR_PARA_LINESPACE_10,
     143             :         SID_ATTR_PARA_LINESPACE_15,
     144             :         SID_ATTR_PARA_LINESPACE_20,
     145             :         SID_ATTR_PARA_ULSPACE,
     146             :         SID_ATTR_PARA_LRSPACE,
     147             :         SID_ATTR_PARA_LEFT_TO_RIGHT,
     148             :         SID_ATTR_PARA_RIGHT_TO_LEFT,
     149             :         SID_RULER_TEXT_RIGHT_TO_LEFT,
     150             :         SID_PARASPACE_INCREASE,
     151             :         SID_PARASPACE_DECREASE,
     152             :         0 };
     153             : 
     154           0 :     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
     155             : }
     156             : 
     157           0 : void FuParagraph::Activate()
     158             : {
     159           0 : }
     160             : 
     161           0 : void FuParagraph::Deactivate()
     162             : {
     163           0 : }
     164             : 
     165          66 : } // end of namespace sd
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11