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

Generated by: LCOV version 1.10