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