1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <hintids.hxx> 32*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 33*cdf0e10cSrcweir #include <sfx2/request.hxx> 34*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 35*cdf0e10cSrcweir #include <svl/stritem.hxx> 36*cdf0e10cSrcweir #include <svl/eitem.hxx> 37*cdf0e10cSrcweir #include <editeng/sizeitem.hxx> 38*cdf0e10cSrcweir #include <fmtfsize.hxx> 39*cdf0e10cSrcweir #include <fldbas.hxx> 40*cdf0e10cSrcweir #include <uiitems.hxx> 41*cdf0e10cSrcweir #include "viewopt.hxx" 42*cdf0e10cSrcweir #include "cmdid.h" 43*cdf0e10cSrcweir #include "view.hxx" 44*cdf0e10cSrcweir #include "wrtsh.hxx" 45*cdf0e10cSrcweir #include "swundo.hxx" // fuer Undo-Ids 46*cdf0e10cSrcweir #include "textsh.hxx" 47*cdf0e10cSrcweir #include "idxmrk.hxx" 48*cdf0e10cSrcweir #include "cnttab.hxx" 49*cdf0e10cSrcweir #include "toxmgr.hxx" 50*cdf0e10cSrcweir #include "swabstdlg.hxx" 51*cdf0e10cSrcweir #include <index.hrc> 52*cdf0e10cSrcweir #include <globals.hrc> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // STATIC DATA ----------------------------------------------------------- 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir void SwTextShell::ExecIdx(SfxRequest &rReq) 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs(); 60*cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 61*cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 62*cdf0e10cSrcweir if(pArgs) 63*cdf0e10cSrcweir pArgs->GetItemState(nSlot, sal_False, &pItem ); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 66*cdf0e10cSrcweir Window *pMDI = &pVFrame->GetWindow(); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir switch( nSlot ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir case FN_EDIT_AUTH_ENTRY_DLG : 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 73*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 74*cdf0e10cSrcweir VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( pMDI, GetShell(), DLG_EDIT_AUTHMARK); 75*cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 76*cdf0e10cSrcweir pDlg->Execute(); 77*cdf0e10cSrcweir delete pDlg; 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir break; 80*cdf0e10cSrcweir case FN_INSERT_AUTH_ENTRY_DLG: 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir // no BASIC support 83*cdf0e10cSrcweir pVFrame->ToggleChildWindow(FN_INSERT_AUTH_ENTRY_DLG); 84*cdf0e10cSrcweir Invalidate(rReq.GetSlot()); 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir break; 87*cdf0e10cSrcweir case FN_INSERT_IDX_ENTRY_DLG: 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir pVFrame->ToggleChildWindow(FN_INSERT_IDX_ENTRY_DLG); 90*cdf0e10cSrcweir Invalidate(rReq.GetSlot()); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir break; 93*cdf0e10cSrcweir case FN_EDIT_IDX_ENTRY_DLG: 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir SwTOXMgr aMgr(GetShellPtr()); 96*cdf0e10cSrcweir sal_uInt16 nRet = RET_OK; 97*cdf0e10cSrcweir if(aMgr.GetTOXMarkCount() > 1) 98*cdf0e10cSrcweir { // Mehrere Marken, welche solls denn sein ? 99*cdf0e10cSrcweir // 100*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 101*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 102*cdf0e10cSrcweir VclAbstractDialog* pMultDlg = pFact->CreateMultiTOXMarkDlg( DLG_MULTMRK, 103*cdf0e10cSrcweir pMDI, aMgr); 104*cdf0e10cSrcweir DBG_ASSERT(pMultDlg, "Dialogdiet fail!"); 105*cdf0e10cSrcweir nRet = pMultDlg->Execute(); 106*cdf0e10cSrcweir delete pMultDlg; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir if( nRet == RET_OK) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 111*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 112*cdf0e10cSrcweir VclAbstractDialog* pDlg = pFact->CreateIndexMarkModalDlg( DLG_EDIT_IDXMARK, pMDI, GetShell(), aMgr.GetCurTOXMark() ); 113*cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 114*cdf0e10cSrcweir pDlg->Execute(); 115*cdf0e10cSrcweir delete pDlg; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir break; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir case FN_IDX_MARK_TO_IDX: 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir GetShell().GotoTOXMarkBase(); 122*cdf0e10cSrcweir break; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir case FN_INSERT_MULTI_TOX: 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir SfxItemSet aSet(GetPool(), 127*cdf0e10cSrcweir RES_COL, RES_COL, 128*cdf0e10cSrcweir RES_BACKGROUND, RES_BACKGROUND, 129*cdf0e10cSrcweir RES_FRM_SIZE, RES_FRM_SIZE, 130*cdf0e10cSrcweir SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 131*cdf0e10cSrcweir RES_LR_SPACE, RES_LR_SPACE, 132*cdf0e10cSrcweir FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE, 133*cdf0e10cSrcweir 0 ); 134*cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 135*cdf0e10cSrcweir SwRect aRect; 136*cdf0e10cSrcweir rSh.CalcBoundRect(aRect, FLY_AS_CHAR); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir long nWidth = aRect.Width(); 139*cdf0e10cSrcweir aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); 140*cdf0e10cSrcweir // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) 141*cdf0e10cSrcweir aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); 142*cdf0e10cSrcweir const SwTOXBase* pCurTOX = 0; 143*cdf0e10cSrcweir sal_Bool bGlobal = sal_False; 144*cdf0e10cSrcweir if(pItem) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir pCurTOX = (const SwTOXBase* )((SwPtrItem*)pItem)->GetValue(); 147*cdf0e10cSrcweir bGlobal = sal_True; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir else 150*cdf0e10cSrcweir pCurTOX = rSh.GetCurTOX(); 151*cdf0e10cSrcweir if(pCurTOX) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir const SfxItemSet* pSet = pCurTOX->GetAttrSet(); 154*cdf0e10cSrcweir if(pSet) 155*cdf0e10cSrcweir aSet.Put(*pSet); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 158*cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 159*cdf0e10cSrcweir AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( DLG_MULTI_TOX, 160*cdf0e10cSrcweir pMDI, aSet, rSh, (SwTOXBase* )pCurTOX, 161*cdf0e10cSrcweir USHRT_MAX, bGlobal); 162*cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 163*cdf0e10cSrcweir pDlg->Execute(); 164*cdf0e10cSrcweir delete pDlg; 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir break; 167*cdf0e10cSrcweir case FN_REMOVE_CUR_TOX: 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 170*cdf0e10cSrcweir const SwTOXBase* pBase = rSh.GetCurTOX(); 171*cdf0e10cSrcweir DBG_ASSERT(pBase, "no TOXBase to remove"); 172*cdf0e10cSrcweir if( pBase ) 173*cdf0e10cSrcweir rSh.DeleteTOX(*pBase, sal_True); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir break; 176*cdf0e10cSrcweir default: 177*cdf0e10cSrcweir ASSERT(!this, falscher Dispatcher); 178*cdf0e10cSrcweir return; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir void SwTextShell::GetIdxState(SfxItemSet &rSet) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 186*cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 187*cdf0e10cSrcweir SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*) 188*cdf0e10cSrcweir pVFrame->GetChildWindow(FN_INSERT_IDX_ENTRY_DLG); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir SfxChildWindow* pAuthMark = pVFrame->GetChildWindow(FN_INSERT_AUTH_ENTRY_DLG); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir const sal_Bool bHtmlMode = 0 != ::GetHtmlMode( GetView().GetDocShell() ); 193*cdf0e10cSrcweir const SwTOXBase* pBase = 0; 194*cdf0e10cSrcweir if( bHtmlMode || 0 != ( pBase = rSh.GetCurTOX()) ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir if( pBase ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir if(pBase->IsTOXBaseInReadonly()) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir rSet.DisableItem( FN_INSERT_MULTI_TOX ); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG ); 205*cdf0e10cSrcweir rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir if(!pIdxMrk) 208*cdf0e10cSrcweir rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG ); 209*cdf0e10cSrcweir else 210*cdf0e10cSrcweir rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, sal_True)); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir if(!pAuthMark) 213*cdf0e10cSrcweir rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG ); 214*cdf0e10cSrcweir else 215*cdf0e10cSrcweir rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, sal_True)); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir else //if( SFX_ITEM_UNKNOWN != rSet.GetItemState( FN_EDIT_IDX_ENTRY_DLG )) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir sal_Bool bEnableEdit = sal_True; 222*cdf0e10cSrcweir sal_Bool bInReadonly = rSh.HasReadonlySel(); 223*cdf0e10cSrcweir if( rSh.HasSelection() || bInReadonly) 224*cdf0e10cSrcweir bEnableEdit = sal_False; 225*cdf0e10cSrcweir else 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir SwTOXMarks aArr; 228*cdf0e10cSrcweir rSh.GetCurTOXMarks( aArr ); 229*cdf0e10cSrcweir if( !aArr.Count()) 230*cdf0e10cSrcweir bEnableEdit = sal_False; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir if(!bEnableEdit) 234*cdf0e10cSrcweir rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir if(bInReadonly) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir rSet.DisableItem(FN_INSERT_IDX_ENTRY_DLG); 239*cdf0e10cSrcweir rSet.DisableItem( FN_INSERT_MULTI_TOX ); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, 243*cdf0e10cSrcweir 0 != pIdxMrk)); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir SwField* pField = rSh.GetCurFld(); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir if(bInReadonly) 249*cdf0e10cSrcweir rSet.DisableItem(FN_INSERT_AUTH_ENTRY_DLG); 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, 0 != pAuthMark)); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir if( bInReadonly || !pField || 254*cdf0e10cSrcweir pField->GetTyp()->Which() != RES_AUTHORITY) 255*cdf0e10cSrcweir rSet.DisableItem(FN_EDIT_AUTH_ENTRY_DLG); 256*cdf0e10cSrcweir rSet.DisableItem(FN_REMOVE_CUR_TOX); 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir // ----------------------------------------------------------------------- 261*cdf0e10cSrcweir 262