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" // fuer 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 : // STATIC DATA -----------------------------------------------------------
45 0 : void SwTextShell::ExecIdx(SfxRequest &rReq)
46 : {
47 0 : const SfxItemSet *pArgs = rReq.GetArgs();
48 0 : const SfxPoolItem* pItem = 0;
49 0 : sal_uInt16 nSlot = rReq.GetSlot();
50 0 : if(pArgs)
51 0 : pArgs->GetItemState(nSlot, sal_False, &pItem );
52 :
53 0 : SfxViewFrame* pVFrame = GetView().GetViewFrame();
54 0 : Window *pMDI = &pVFrame->GetWindow();
55 :
56 0 : switch( nSlot )
57 : {
58 : case FN_EDIT_AUTH_ENTRY_DLG :
59 : {
60 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
61 : OSL_ENSURE(pFact, "Dialogdiet fail!");
62 0 : VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( pMDI, GetShell(), DLG_EDIT_AUTHMARK);
63 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
64 0 : pDlg->Execute();
65 0 : delete pDlg;
66 : }
67 0 : break;
68 : case FN_INSERT_AUTH_ENTRY_DLG:
69 : {
70 : // no BASIC support
71 0 : pVFrame->ToggleChildWindow(FN_INSERT_AUTH_ENTRY_DLG);
72 0 : Invalidate(rReq.GetSlot());
73 : }
74 0 : break;
75 : case FN_INSERT_IDX_ENTRY_DLG:
76 : {
77 0 : pVFrame->ToggleChildWindow(FN_INSERT_IDX_ENTRY_DLG);
78 0 : Invalidate(rReq.GetSlot());
79 : }
80 0 : break;
81 : case FN_EDIT_IDX_ENTRY_DLG:
82 : {
83 0 : SwTOXMgr aMgr(GetShellPtr());
84 0 : sal_uInt16 nRet = RET_OK;
85 0 : if(aMgr.GetTOXMarkCount() > 1)
86 : { // Mehrere Marken, welche solls denn sein ?
87 : //
88 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
89 : OSL_ENSURE(pFact, "Dialogdiet fail!");
90 : VclAbstractDialog* pMultDlg = pFact->CreateMultiTOXMarkDlg( DLG_MULTMRK,
91 0 : pMDI, aMgr);
92 : OSL_ENSURE(pMultDlg, "Dialogdiet fail!");
93 0 : nRet = pMultDlg->Execute();
94 0 : delete pMultDlg;
95 : }
96 0 : if( nRet == RET_OK)
97 : {
98 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
99 : OSL_ENSURE(pFact, "Dialogdiet fail!");
100 0 : VclAbstractDialog* pDlg = pFact->CreateIndexMarkModalDlg(pMDI, GetShell(), aMgr.GetCurTOXMark());
101 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
102 0 : pDlg->Execute();
103 0 : delete pDlg;
104 : }
105 0 : break;
106 : }
107 : case FN_IDX_MARK_TO_IDX:
108 : {
109 0 : GetShell().GotoTOXMarkBase();
110 0 : break;
111 : }
112 : case FN_INSERT_MULTI_TOX:
113 : {
114 0 : SfxItemSet aSet(GetPool(),
115 : RES_COL, RES_COL,
116 : RES_BACKGROUND, RES_BACKGROUND,
117 : RES_FRM_SIZE, RES_FRM_SIZE,
118 : SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
119 : RES_LR_SPACE, RES_LR_SPACE,
120 : FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE,
121 0 : 0 );
122 0 : SwWrtShell& rSh = GetShell();
123 0 : SwRect aRect;
124 0 : rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
125 :
126 0 : long nWidth = aRect.Width();
127 0 : aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
128 : // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten)
129 0 : aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
130 0 : const SwTOXBase* pCurTOX = 0;
131 0 : sal_Bool bGlobal = sal_False;
132 0 : if(pItem)
133 : {
134 0 : pCurTOX = (const SwTOXBase* )((SwPtrItem*)pItem)->GetValue();
135 0 : bGlobal = sal_True;
136 : }
137 : else
138 0 : pCurTOX = rSh.GetCurTOX();
139 0 : if(pCurTOX)
140 : {
141 0 : const SfxItemSet* pSet = pCurTOX->GetAttrSet();
142 0 : if(pSet)
143 0 : aSet.Put(*pSet);
144 : }
145 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
146 : OSL_ENSURE(pFact, "Dialogdiet fail!");
147 : AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( DLG_MULTI_TOX,
148 : pMDI, aSet, rSh, (SwTOXBase* )pCurTOX,
149 0 : USHRT_MAX, bGlobal);
150 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
151 0 : pDlg->Execute();
152 0 : delete pDlg;
153 : }
154 0 : break;
155 : case FN_REMOVE_CUR_TOX:
156 : {
157 0 : SwWrtShell& rSh = GetShell();
158 0 : const SwTOXBase* pBase = rSh.GetCurTOX();
159 : OSL_ENSURE(pBase, "no TOXBase to remove");
160 0 : if( pBase )
161 0 : rSh.DeleteTOX(*pBase, true);
162 : }
163 0 : break;
164 : default:
165 : OSL_ENSURE(!this, "wrong dispatcher");
166 0 : return;
167 : }
168 : }
169 :
170 0 : void SwTextShell::GetIdxState(SfxItemSet &rSet)
171 : {
172 0 : SwWrtShell& rSh = GetShell();
173 0 : SfxViewFrame* pVFrame = GetView().GetViewFrame();
174 : SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)
175 0 : pVFrame->GetChildWindow(FN_INSERT_IDX_ENTRY_DLG);
176 :
177 0 : SfxChildWindow* pAuthMark = pVFrame->GetChildWindow(FN_INSERT_AUTH_ENTRY_DLG);
178 :
179 0 : const sal_Bool bHtmlMode = 0 != ::GetHtmlMode( GetView().GetDocShell() );
180 0 : const SwTOXBase* pBase = 0;
181 0 : if( bHtmlMode || 0 != ( pBase = rSh.GetCurTOX()) )
182 : {
183 0 : if( pBase )
184 : {
185 0 : if(pBase->IsTOXBaseInReadonly())
186 : {
187 0 : rSet.DisableItem( FN_INSERT_MULTI_TOX );
188 : }
189 : }
190 :
191 0 : rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
192 0 : rSet.DisableItem( FN_EDIT_AUTH_ENTRY_DLG );
193 :
194 0 : if(!pIdxMrk)
195 0 : rSet.DisableItem( FN_INSERT_IDX_ENTRY_DLG );
196 : else
197 0 : rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG, sal_True));
198 :
199 0 : if(!pAuthMark)
200 0 : rSet.DisableItem( FN_INSERT_AUTH_ENTRY_DLG );
201 : else
202 0 : rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, sal_True));
203 :
204 : }
205 : else
206 : {
207 :
208 0 : sal_Bool bEnableEdit = sal_True;
209 0 : sal_Bool bInReadonly = rSh.HasReadonlySel();
210 0 : if( rSh.HasSelection() || bInReadonly)
211 0 : bEnableEdit = sal_False;
212 : else
213 : {
214 0 : SwTOXMarks aArr;
215 0 : rSh.GetCurTOXMarks( aArr );
216 0 : if( aArr.empty())
217 0 : bEnableEdit = sal_False;
218 : }
219 :
220 0 : if(!bEnableEdit)
221 0 : rSet.DisableItem( FN_EDIT_IDX_ENTRY_DLG );
222 :
223 0 : if(bInReadonly)
224 : {
225 0 : rSet.DisableItem(FN_INSERT_IDX_ENTRY_DLG);
226 0 : rSet.DisableItem( FN_INSERT_MULTI_TOX );
227 : }
228 : else
229 : rSet.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG,
230 0 : 0 != pIdxMrk));
231 :
232 :
233 0 : SwField* pField = rSh.GetCurFld();
234 :
235 0 : if(bInReadonly)
236 0 : rSet.DisableItem(FN_INSERT_AUTH_ENTRY_DLG);
237 : else
238 0 : rSet.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG, 0 != pAuthMark));
239 :
240 0 : if( bInReadonly || !pField ||
241 0 : pField->GetTyp()->Which() != RES_AUTHORITY)
242 0 : rSet.DisableItem(FN_EDIT_AUTH_ENTRY_DLG);
243 0 : rSet.DisableItem(FN_REMOVE_CUR_TOX);
244 : }
245 30 : }
246 :
247 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|