LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - textidx.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 113 0.0 %
Date: 2014-04-14 Functions: 0 4 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 <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             : 
      43           0 : void SwTextShell::ExecIdx(SfxRequest &rReq)
      44             : {
      45           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
      46           0 :     const SfxPoolItem* pItem = 0;
      47           0 :     sal_uInt16 nSlot = rReq.GetSlot();
      48           0 :     if(pArgs)
      49           0 :        pArgs->GetItemState(nSlot, false, &pItem );
      50             : 
      51           0 :     SfxViewFrame* pVFrame = GetView().GetViewFrame();
      52           0 :     Window *pMDI = &pVFrame->GetWindow();
      53             : 
      54           0 :     switch( nSlot )
      55             :     {
      56             :         case FN_EDIT_AUTH_ENTRY_DLG :
      57             :         {
      58           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      59             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
      60           0 :             VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( pMDI, GetShell(), DLG_EDIT_AUTHMARK);
      61             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
      62           0 :             pDlg->Execute();
      63           0 :             delete pDlg;
      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 :             sal_uInt16 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, "Dialogdiet fail!");
      87           0 :                 VclAbstractDialog* pMultDlg = pFact->CreateMultiTOXMarkDlg(pMDI, aMgr);
      88             :                 OSL_ENSURE(pMultDlg, "Dialogdiet fail!");
      89           0 :                 nRet = pMultDlg->Execute();
      90           0 :                 delete pMultDlg;
      91             :             }
      92           0 :             if( nRet == RET_OK)
      93             :             {
      94           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      95             :                 OSL_ENSURE(pFact, "Dialogdiet fail!");
      96           0 :                 VclAbstractDialog* pDlg = pFact->CreateIndexMarkModalDlg(pMDI, GetShell(), aMgr.GetCurTOXMark());
      97             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
      98           0 :                 pDlg->Execute();
      99           0 :                 delete pDlg;
     100             :             }
     101           0 :             break;
     102             :         }
     103             :         case FN_IDX_MARK_TO_IDX:
     104             :         {
     105           0 :             GetShell().GotoTOXMarkBase();
     106           0 :             break;
     107             :         }
     108             :         case FN_INSERT_MULTI_TOX:
     109             :         {
     110           0 :             SfxItemSet aSet(GetPool(),
     111             :                             RES_COL, RES_COL,
     112             :                             RES_BACKGROUND, RES_BACKGROUND,
     113             :                             RES_FRM_SIZE, RES_FRM_SIZE,
     114             :                             SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
     115             :                             RES_LR_SPACE, RES_LR_SPACE,
     116             :                             FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE,
     117           0 :                             0   );
     118           0 :             SwWrtShell& rSh = GetShell();
     119           0 :             SwRect aRect;
     120           0 :             rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
     121             : 
     122           0 :             long nWidth = aRect.Width();
     123           0 :             aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
     124             :             // Height = width for a more consistent preview (analogous to edit range)
     125           0 :             aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
     126           0 :             const SwTOXBase* pCurTOX = 0;
     127           0 :             sal_Bool bGlobal = sal_False;
     128           0 :             if(pItem)
     129             :             {
     130           0 :                 pCurTOX = (const SwTOXBase* )((SwPtrItem*)pItem)->GetValue();
     131           0 :                 bGlobal = sal_True;
     132             :             }
     133             :             else
     134           0 :                 pCurTOX = rSh.GetCurTOX();
     135           0 :             if(pCurTOX)
     136             :             {
     137           0 :                 const SfxItemSet* pSet = pCurTOX->GetAttrSet();
     138           0 :                 if(pSet)
     139           0 :                     aSet.Put(*pSet);
     140             :             }
     141           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     142             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
     143             :             AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog(
     144             :                                                         pMDI, aSet, rSh, (SwTOXBase* )pCurTOX,
     145           0 :                                                         USHRT_MAX, bGlobal);
     146             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     147           0 :             pDlg->Execute();
     148           0 :             delete pDlg;
     149             :         }
     150           0 :         break;
     151             :         case FN_REMOVE_CUR_TOX:
     152             :         {
     153           0 :             SwWrtShell& rSh = GetShell();
     154           0 :             const SwTOXBase* pBase = rSh.GetCurTOX();
     155             :             OSL_ENSURE(pBase, "no TOXBase to remove");
     156           0 :             if( pBase )
     157           0 :                 rSh.DeleteTOX(*pBase, true);
     158             :         }
     159           0 :         break;
     160             :         default:
     161             :             OSL_ENSURE(!this, "wrong dispatcher");
     162           0 :             return;
     163             :     }
     164             : }
     165             : 
     166           0 : void SwTextShell::GetIdxState(SfxItemSet &rSet)
     167             : {
     168           0 :     SwWrtShell& rSh = GetShell();
     169           0 :     SfxViewFrame* pVFrame = GetView().GetViewFrame();
     170             :     SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)
     171           0 :                         pVFrame->GetChildWindow(FN_INSERT_IDX_ENTRY_DLG);
     172             : 
     173           0 :     SfxChildWindow* pAuthMark = pVFrame->GetChildWindow(FN_INSERT_AUTH_ENTRY_DLG);
     174             : 
     175           0 :     const bool bHtmlMode = 0 != ::GetHtmlMode( GetView().GetDocShell() );
     176           0 :     const SwTOXBase* pBase = 0;
     177           0 :     if( bHtmlMode || 0 != ( pBase = rSh.GetCurTOX()) )
     178             :     {
     179           0 :         if( pBase )
     180             :         {
     181           0 :             if(pBase->IsTOXBaseInReadonly())
     182             :             {
     183           0 :                 rSet.DisableItem( FN_INSERT_MULTI_TOX );
     184             :             }
     185             :         }
     186             : 
     187           0 :         rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
     188           0 :         rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG );
     189             : 
     190           0 :         if(!pIdxMrk)
     191           0 :             rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG );
     192             :         else
     193           0 :             rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, true));
     194             : 
     195           0 :         if(!pAuthMark)
     196           0 :             rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG );
     197             :         else
     198           0 :             rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, true));
     199             : 
     200             :     }
     201           0 :     else if ( rSh.CrsrInsideInputFld() )
     202             :     {
     203           0 :         rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG );
     204           0 :         rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG );
     205           0 :         rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG );
     206           0 :         rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
     207           0 :         rSet.DisableItem( FN_INSERT_MULTI_TOX );
     208           0 :         rSet.DisableItem( FN_REMOVE_CUR_TOX );
     209             :     }
     210             :     else
     211             :     {
     212             : 
     213           0 :         bool bEnableEdit = true;
     214           0 :         sal_Bool bInReadonly = rSh.HasReadonlySel();
     215           0 :         if( rSh.HasSelection() || bInReadonly)
     216           0 :             bEnableEdit = false;
     217             :         else
     218             :         {
     219           0 :             SwTOXMarks aArr;
     220           0 :             rSh.GetCurTOXMarks( aArr );
     221           0 :             if( aArr.empty())
     222           0 :                 bEnableEdit = false;
     223             :         }
     224             : 
     225           0 :         if(!bEnableEdit)
     226           0 :             rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
     227             : 
     228           0 :         if(bInReadonly)
     229             :         {
     230           0 :             rSet.DisableItem(FN_INSERT_IDX_ENTRY_DLG);
     231           0 :             rSet.DisableItem( FN_INSERT_MULTI_TOX );
     232             :         }
     233             :         else
     234             :             rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG,
     235           0 :                                     0 != pIdxMrk));
     236             : 
     237           0 :         SwField* pField = rSh.GetCurFld();
     238             : 
     239           0 :         if(bInReadonly)
     240           0 :             rSet.DisableItem(FN_INSERT_AUTH_ENTRY_DLG);
     241             :         else
     242           0 :             rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, 0 != pAuthMark));
     243             : 
     244           0 :         if( bInReadonly || !pField ||
     245           0 :             pField->GetTyp()->Which() != RES_AUTHORITY)
     246           0 :             rSet.DisableItem(FN_EDIT_AUTH_ENTRY_DLG);
     247           0 :         rSet.DisableItem(FN_REMOVE_CUR_TOX);
     248             :     }
     249           0 : }
     250             : 
     251             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10