LCOV - code coverage report
Current view: top level - sw/source/uibase/shells - textidx.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 28 109 25.7 %
Date: 2015-06-13 12:38:46 Functions: 3 4 75.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 <hintids.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <sfx2/request.hxx>
      23             : #include <sfx2/viewfrm.hxx>
      24             : #include <svl/stritem.hxx>
      25             : #include <svl/eitem.hxx>
      26             : #include <editeng/sizeitem.hxx>
      27             : #include <fmtfsize.hxx>
      28             : #include <fldbas.hxx>
      29             : #include <uiitems.hxx>
      30             : #include "viewopt.hxx"
      31             : #include "cmdid.h"
      32             : #include "view.hxx"
      33             : #include "wrtsh.hxx"
      34             : #include "swundo.hxx"
      35             : #include "textsh.hxx"
      36             : #include "idxmrk.hxx"
      37             : #include "cnttab.hxx"
      38             : #include "toxmgr.hxx"
      39             : #include "swabstdlg.hxx"
      40             : #include <index.hrc>
      41             : #include <globals.hrc>
      42             : #include <boost/scoped_ptr.hpp>
      43             : 
      44           0 : void SwTextShell::ExecIdx(SfxRequest &rReq)
      45             : {
      46           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
      47           0 :     const SfxPoolItem* pItem = 0;
      48           0 :     const sal_uInt16 nSlot = rReq.GetSlot();
      49           0 :     if(pArgs)
      50           0 :        pArgs->GetItemState(nSlot, false, &pItem );
      51             : 
      52           0 :     SfxViewFrame* pVFrame = GetView().GetViewFrame();
      53           0 :     vcl::Window *pMDI = &pVFrame->GetWindow();
      54             : 
      55           0 :     switch( nSlot )
      56             :     {
      57             :         case FN_EDIT_AUTH_ENTRY_DLG :
      58             :         {
      59           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      60             :             OSL_ENSURE(pFact, "Dialog creation failed!");
      61           0 :             boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclAbstractDialog( pMDI, GetShell(), DLG_EDIT_AUTHMARK));
      62             :             OSL_ENSURE(pDlg, "Dialog creation failed!");
      63           0 :             pDlg->Execute();
      64             :         }
      65           0 :         break;
      66             :         case FN_INSERT_AUTH_ENTRY_DLG:
      67             :         {
      68             :             // no BASIC support
      69           0 :             pVFrame->ToggleChildWindow(FN_INSERT_AUTH_ENTRY_DLG);
      70           0 :             Invalidate(rReq.GetSlot());
      71             :         }
      72           0 :         break;
      73             :         case FN_INSERT_IDX_ENTRY_DLG:
      74             :         {
      75           0 :             pVFrame->ToggleChildWindow(FN_INSERT_IDX_ENTRY_DLG);
      76           0 :             Invalidate(rReq.GetSlot());
      77             :         }
      78           0 :         break;
      79             :         case FN_EDIT_IDX_ENTRY_DLG:
      80             :         {
      81           0 :             SwTOXMgr aMgr(GetShellPtr());
      82           0 :             short nRet = RET_OK;
      83           0 :             if(aMgr.GetTOXMarkCount() > 1)
      84             :             {   // Several marks, which should it be?
      85           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      86             :                 OSL_ENSURE(pFact, "Dialog creation failed!");
      87           0 :                 boost::scoped_ptr<VclAbstractDialog> pMultDlg(pFact->CreateMultiTOXMarkDlg(pMDI, aMgr));
      88             :                 OSL_ENSURE(pMultDlg, "Dialog creation failed!");
      89           0 :                 nRet = pMultDlg->Execute();
      90             :             }
      91           0 :             if( nRet == RET_OK)
      92             :             {
      93           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      94             :                 OSL_ENSURE(pFact, "Dialog creation failed!");
      95           0 :                 boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateIndexMarkModalDlg(pMDI, GetShell(), aMgr.GetCurTOXMark()));
      96             :                 OSL_ENSURE(pDlg, "Dialog creation failed!");
      97           0 :                 pDlg->Execute();
      98             :             }
      99           0 :             break;
     100             :         }
     101             :         case FN_IDX_MARK_TO_IDX:
     102             :         {
     103           0 :             GetShell().GotoTOXMarkBase();
     104           0 :             break;
     105             :         }
     106             :         case FN_INSERT_MULTI_TOX:
     107             :         {
     108           0 :             SfxItemSet aSet(GetPool(),
     109             :                             RES_COL, RES_COL,
     110             :                             RES_BACKGROUND, RES_BACKGROUND,
     111             :                             RES_FRM_SIZE, RES_FRM_SIZE,
     112             :                             SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
     113             :                             RES_LR_SPACE, RES_LR_SPACE,
     114             :                             FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE,
     115           0 :                             0   );
     116           0 :             SwWrtShell& rSh = GetShell();
     117           0 :             SwRect aRect;
     118           0 :             rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
     119             : 
     120           0 :             long nWidth = aRect.Width();
     121           0 :             aSet.Put(SwFormatFrmSize(ATT_VAR_SIZE, nWidth));
     122             :             // Height = width for a more consistent preview (analogous to edit range)
     123           0 :             aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
     124           0 :             const SwTOXBase* pCurTOX = 0;
     125           0 :             bool bGlobal = false;
     126           0 :             if(pItem)
     127             :             {
     128           0 :                 pCurTOX = static_cast<const SwTOXBase*>(static_cast<const SwPtrItem*>(pItem)->GetValue());
     129           0 :                 bGlobal = true;
     130             :             }
     131             :             else
     132           0 :                 pCurTOX = rSh.GetCurTOX();
     133           0 :             if(pCurTOX)
     134             :             {
     135           0 :                 const SfxItemSet* pSet = pCurTOX->GetAttrSet();
     136           0 :                 if(pSet)
     137           0 :                     aSet.Put(*pSet);
     138             :             }
     139           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     140             :             OSL_ENSURE(pFact, "Dialog creation failed!");
     141             :             boost::scoped_ptr<AbstractMultiTOXTabDialog> pDlg(pFact->CreateMultiTOXTabDialog(
     142             :                                                         pMDI, aSet, rSh, const_cast<SwTOXBase*>(pCurTOX),
     143           0 :                                                         USHRT_MAX, bGlobal));
     144             :             OSL_ENSURE(pDlg, "Dialog creation failed!");
     145           0 :             pDlg->Execute();
     146             :         }
     147           0 :         break;
     148             :         case FN_REMOVE_CUR_TOX:
     149             :         {
     150           0 :             SwWrtShell& rSh = GetShell();
     151           0 :             const SwTOXBase* pBase = rSh.GetCurTOX();
     152             :             OSL_ENSURE(pBase, "no TOXBase to remove");
     153           0 :             if( pBase )
     154           0 :                 rSh.DeleteTOX(*pBase, true);
     155             :         }
     156           0 :         break;
     157             :         default:
     158             :             OSL_ENSURE(false, "wrong dispatcher");
     159           0 :             return;
     160             :     }
     161             : }
     162             : 
     163         694 : void SwTextShell::GetIdxState(SfxItemSet &rSet)
     164             : {
     165         694 :     SwWrtShell& rSh = GetShell();
     166         694 :     SfxViewFrame* pVFrame = GetView().GetViewFrame();
     167             :     SwInsertIdxMarkWrapper *pIdxMrk = static_cast<SwInsertIdxMarkWrapper*>(
     168         694 :                         pVFrame->GetChildWindow(FN_INSERT_IDX_ENTRY_DLG));
     169             : 
     170         694 :     SfxChildWindow* pAuthMark = pVFrame->GetChildWindow(FN_INSERT_AUTH_ENTRY_DLG);
     171             : 
     172         694 :     const bool bHtmlMode = 0 != ::GetHtmlMode( GetView().GetDocShell() );
     173         694 :     const SwTOXBase* pBase = 0;
     174         694 :     if( bHtmlMode || 0 != ( pBase = rSh.GetCurTOX()) )
     175             :     {
     176           0 :         if( pBase )
     177             :         {
     178           0 :             if(pBase->IsTOXBaseInReadonly())
     179             :             {
     180           0 :                 rSet.DisableItem( FN_INSERT_MULTI_TOX );
     181             :             }
     182             :         }
     183             : 
     184           0 :         rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
     185           0 :         rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG );
     186             : 
     187           0 :         if(!pIdxMrk)
     188           0 :             rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG );
     189             :         else
     190           0 :             rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, true));
     191             : 
     192           0 :         if(!pAuthMark)
     193           0 :             rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG );
     194             :         else
     195           0 :             rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, true));
     196             : 
     197             :     }
     198         694 :     else if ( rSh.CrsrInsideInputField() )
     199             :     {
     200           0 :         rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG );
     201           0 :         rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG );
     202           0 :         rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG );
     203           0 :         rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
     204           0 :         rSet.DisableItem( FN_INSERT_MULTI_TOX );
     205           0 :         rSet.DisableItem( FN_REMOVE_CUR_TOX );
     206             :     }
     207             :     else
     208             :     {
     209             : 
     210         694 :         bool bEnableEdit = true;
     211         694 :         bool bInReadonly = rSh.HasReadonlySel();
     212         694 :         if( rSh.HasSelection() || bInReadonly)
     213           4 :             bEnableEdit = false;
     214             :         else
     215             :         {
     216         690 :             SwTOXMarks aArr;
     217         690 :             rSh.GetCurTOXMarks( aArr );
     218         690 :             if( aArr.empty())
     219         690 :                 bEnableEdit = false;
     220             :         }
     221             : 
     222         694 :         if(!bEnableEdit)
     223         694 :             rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
     224             : 
     225         694 :         if(bInReadonly)
     226             :         {
     227           0 :             rSet.DisableItem(FN_INSERT_IDX_ENTRY_DLG);
     228           0 :             rSet.DisableItem( FN_INSERT_MULTI_TOX );
     229             :         }
     230             :         else
     231             :             rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG,
     232         694 :                                     0 != pIdxMrk));
     233             : 
     234         694 :         SwField* pField = rSh.GetCurField();
     235             : 
     236         694 :         if(bInReadonly)
     237           0 :             rSet.DisableItem(FN_INSERT_AUTH_ENTRY_DLG);
     238             :         else
     239         694 :             rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, 0 != pAuthMark));
     240             : 
     241         694 :         if( bInReadonly || !pField ||
     242           0 :             pField->GetTyp()->Which() != RES_AUTHORITY)
     243         694 :             rSet.DisableItem(FN_EDIT_AUTH_ENTRY_DLG);
     244         694 :         rSet.DisableItem(FN_REMOVE_CUR_TOX);
     245             :     }
     246         871 : }
     247             : 
     248             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11