1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textidx.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include <hintids.hxx>
35 #ifndef _MSGBOX_HXX //autogen
36 #include <vcl/msgbox.hxx>
38 #include <sfx2/request.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <svtools/stritem.hxx>
41 #include <svtools/eitem.hxx>
42 #include <svx/sizeitem.hxx>
43 #include <fmtfsize.hxx>
45 #include <uiitems.hxx>
46 #include "viewopt.hxx"
50 #include "swundo.hxx" // fuer Undo-Ids
55 #include "swabstdlg.hxx"
57 #include <globals.hrc>
58 // STATIC DATA -----------------------------------------------------------
60 void SwTextShell::ExecIdx(SfxRequest
&rReq
)
62 const SfxItemSet
*pArgs
= rReq
.GetArgs();
63 const SfxPoolItem
* pItem
= 0;
64 USHORT nSlot
= rReq
.GetSlot();
66 pArgs
->GetItemState(nSlot
, FALSE
, &pItem
);
68 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
69 Window
*pMDI
= &pVFrame
->GetWindow();
73 case FN_EDIT_AUTH_ENTRY_DLG
:
75 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
76 DBG_ASSERT(pFact
, "Dialogdiet fail!");
77 VclAbstractDialog
* pDlg
= pFact
->CreateVclAbstractDialog( pMDI
, GetShell(), DLG_EDIT_AUTHMARK
);
78 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
83 case FN_INSERT_AUTH_ENTRY_DLG
:
86 pVFrame
->ToggleChildWindow(FN_INSERT_AUTH_ENTRY_DLG
);
87 Invalidate(rReq
.GetSlot());
90 case FN_INSERT_IDX_ENTRY_DLG
:
92 pVFrame
->ToggleChildWindow(FN_INSERT_IDX_ENTRY_DLG
);
93 Invalidate(rReq
.GetSlot());
96 case FN_EDIT_IDX_ENTRY_DLG
:
98 SwTOXMgr
aMgr(GetShellPtr());
100 if(aMgr
.GetTOXMarkCount() > 1)
101 { // Mehrere Marken, welche solls denn sein ?
103 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
104 DBG_ASSERT(pFact
, "Dialogdiet fail!");
105 VclAbstractDialog
* pMultDlg
= pFact
->CreateMultiTOXMarkDlg( DLG_MULTMRK
,
107 DBG_ASSERT(pMultDlg
, "Dialogdiet fail!");
108 nRet
= pMultDlg
->Execute();
113 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
114 DBG_ASSERT(pFact
, "Dialogdiet fail!");
115 VclAbstractDialog
* pDlg
= pFact
->CreateIndexMarkModalDlg( DLG_EDIT_IDXMARK
, pMDI
, GetShell(), aMgr
.GetCurTOXMark() );
116 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
122 case FN_IDX_MARK_TO_IDX
:
124 GetShell().GotoTOXMarkBase();
127 case FN_INSERT_MULTI_TOX
:
129 SfxItemSet
aSet(GetPool(),
131 RES_BACKGROUND
, RES_BACKGROUND
,
132 RES_FRM_SIZE
, RES_FRM_SIZE
,
133 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
134 RES_LR_SPACE
, RES_LR_SPACE
,
135 FN_PARAM_TOX_TYPE
, FN_PARAM_TOX_TYPE
,
137 SwWrtShell
& rSh
= GetShell();
139 rSh
.CalcBoundRect(aRect
, FLY_IN_CNTNT
);
141 long nWidth
= aRect
.Width();
142 aSet
.Put(SwFmtFrmSize(ATT_VAR_SIZE
, nWidth
));
143 // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten)
144 aSet
.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE
, Size(nWidth
, nWidth
)));
145 const SwTOXBase
* pCurTOX
= 0;
146 BOOL bGlobal
= FALSE
;
149 pCurTOX
= (const SwTOXBase
* )((SwPtrItem
*)pItem
)->GetValue();
153 pCurTOX
= rSh
.GetCurTOX();
156 const SfxItemSet
* pSet
= pCurTOX
->GetAttrSet();
160 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
161 DBG_ASSERT(pFact
, "Dialogdiet fail!");
162 AbstractMultiTOXTabDialog
* pDlg
= pFact
->CreateMultiTOXTabDialog( DLG_MULTI_TOX
,
163 pMDI
, aSet
, rSh
, (SwTOXBase
* )pCurTOX
,
165 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
170 case FN_REMOVE_CUR_TOX
:
172 SwWrtShell
& rSh
= GetShell();
173 const SwTOXBase
* pBase
= rSh
.GetCurTOX();
174 DBG_ASSERT(pBase
, "no TOXBase to remove");
176 rSh
.DeleteTOX(*pBase
, TRUE
);
180 ASSERT(!this, falscher Dispatcher
);
186 void SwTextShell::GetIdxState(SfxItemSet
&rSet
)
188 SwWrtShell
& rSh
= GetShell();
189 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
190 SwInsertIdxMarkWrapper
*pIdxMrk
= (SwInsertIdxMarkWrapper
*)
191 pVFrame
->GetChildWindow(FN_INSERT_IDX_ENTRY_DLG
);
193 SfxChildWindow
* pAuthMark
= pVFrame
->GetChildWindow(FN_INSERT_AUTH_ENTRY_DLG
);
195 const BOOL bHtmlMode
= 0 != ::GetHtmlMode( GetView().GetDocShell() );
196 const SwTOXBase
* pBase
= 0;
197 if( bHtmlMode
|| 0 != ( pBase
= rSh
.GetCurTOX()) )
201 if(pBase
->IsTOXBaseInReadonly())
203 rSet
.DisableItem( FN_INSERT_MULTI_TOX
);
207 rSet
.DisableItem( FN_EDIT_IDX_ENTRY_DLG
);
208 rSet
.DisableItem( FN_EDIT_AUTH_ENTRY_DLG
);
211 rSet
.DisableItem( FN_INSERT_IDX_ENTRY_DLG
);
213 rSet
.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG
, TRUE
));
216 rSet
.DisableItem( FN_INSERT_AUTH_ENTRY_DLG
);
218 rSet
.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG
, TRUE
));
221 else //if( SFX_ITEM_UNKNOWN != rSet.GetItemState( FN_EDIT_IDX_ENTRY_DLG ))
224 BOOL bEnableEdit
= TRUE
;
225 BOOL bInReadonly
= rSh
.HasReadonlySel();
226 if( rSh
.HasSelection() || bInReadonly
)
231 rSh
.GetCurTOXMarks( aArr
);
237 rSet
.DisableItem( FN_EDIT_IDX_ENTRY_DLG
);
241 rSet
.DisableItem(FN_INSERT_IDX_ENTRY_DLG
);
242 rSet
.DisableItem( FN_INSERT_MULTI_TOX
);
245 rSet
.Put(SfxBoolItem(FN_INSERT_IDX_ENTRY_DLG
,
249 SwField
* pField
= rSh
.GetCurFld();
252 rSet
.DisableItem(FN_INSERT_AUTH_ENTRY_DLG
);
254 rSet
.Put(SfxBoolItem(FN_INSERT_AUTH_ENTRY_DLG
, 0 != pAuthMark
));
256 if( bInReadonly
|| !pField
||
257 pField
->GetTyp()->Which() != RES_AUTHORITY
)
258 rSet
.DisableItem(FN_EDIT_AUTH_ENTRY_DLG
);
259 rSet
.DisableItem(FN_REMOVE_CUR_TOX
);
263 // -----------------------------------------------------------------------