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