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