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 : : #include "swuiidxmrk.hxx"
30 : : #include <hintids.hxx>
31 : : #include <helpid.h>
32 : : #include <comphelper/processfactory.hxx>
33 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 : : #include <com/sun/star/beans/PropertyValue.hpp>
35 : : #include <com/sun/star/beans/XPropertySet.hpp>
36 : : #include <com/sun/star/util/SearchOptions.hpp>
37 : : #include <com/sun/star/util/SearchFlags.hpp>
38 : : #include <com/sun/star/i18n/TransliterationModules.hpp>
39 : : #include <svl/stritem.hxx>
40 : : #include <vcl/msgbox.hxx>
41 : : #include <sfx2/dispatch.hxx>
42 : : #include <svl/eitem.hxx>
43 : : #include <svtools/txtcmp.hxx>
44 : : #include <editeng/scripttypeitem.hxx>
45 : : #include <svl/itemset.hxx>
46 : : #include <editeng/langitem.hxx>
47 : : #include "editeng/unolingu.hxx"
48 : : #include <swtypes.hxx>
49 : : #include <idxmrk.hxx>
50 : : #include <txttxmrk.hxx>
51 : : #include <wrtsh.hxx>
52 : : #include <view.hxx>
53 : : #include <multmrk.hxx>
54 : : #include <swundo.hxx> // for Undo-Ids
55 : : #include <cmdid.h>
56 : : #include <index.hrc>
57 : : #include <idxmrk.hrc>
58 : : #include <swmodule.hxx>
59 : : #include <fldmgr.hxx>
60 : : #include <fldbas.hxx>
61 : : #include <utlui.hrc>
62 : : #include <swcont.hxx>
63 : : #include <svl/cjkoptions.hxx>
64 : : #include <ndtxt.hxx>
65 : : #include <breakit.hxx>
66 : : #include <SwRewriter.hxx>
67 : :
68 : : #include <unomid.h>
69 : :
70 : :
71 : : #define POS_CONTENT 0
72 : : #define POS_INDEX 1
73 : : #define POS_USER 2
74 : :
75 : : static sal_uInt16 nTypePos = 1; // TOX_INDEX as standard
76 : : static sal_uInt16 nKey1Pos = USHRT_MAX;
77 : :
78 : : static sal_uInt16 nKey2Pos = USHRT_MAX;
79 : :
80 : : using namespace com::sun::star;
81 : : using namespace com::sun::star::i18n;
82 : : using namespace com::sun::star::lang;
83 : : using namespace com::sun::star::util;
84 : : using namespace com::sun::star::i18n;
85 : : using ::rtl::OUString;
86 : : using namespace ::comphelper;
87 : : using namespace ::com::sun::star;
88 : :
89 : : /*--------------------------------------------------------------------
90 : : Description: dialog to insert a directory selection
91 : : --------------------------------------------------------------------*/
92 : 0 : SwIndexMarkDlg::SwIndexMarkDlg(Window *pParent,
93 : : sal_Bool bNewDlg,
94 : : const ResId& rResId,
95 : : sal_Int32 _nOptionsId, SwWrtShell& rWrtShell ) :
96 : : Window(pParent, rResId),
97 : : aIndexFL(this, SW_RES(FL_INDEX )),
98 : : aTypeFT (this, SW_RES(LBL_INDEX )),
99 : : aTypeDCB(this, SW_RES(DCB_INDEX )),
100 : : aNewBT(this, SW_RES(BT_NEW )),
101 : :
102 : : aEntryFT(this, SW_RES(LBL_ENTRY )),
103 : : aEntryED(this, SW_RES(SL_ENTRY )),
104 : : aPhoneticFT0(this, SW_RES(FT_PHONETIC_1 )),
105 : : aPhoneticED0(this, SW_RES(ED_PHONETIC_1 )),
106 : :
107 : : aKeyFT(this, SW_RES(LBL_KEY )),
108 : : aKeyDCB(this, SW_RES(DCB_KEY )),
109 : : aPhoneticFT1(this, SW_RES(FT_PHONETIC_2 )),
110 : : aPhoneticED1(this, SW_RES(ED_PHONETIC_2 )),
111 : :
112 : : aKey2FT(this, SW_RES(LBL_KEY2 )),
113 : : aKey2DCB(this, SW_RES(DCB_KEY2 )),
114 : : aPhoneticFT2(this, SW_RES(FT_PHONETIC_3 )),
115 : : aPhoneticED2(this, SW_RES(ED_PHONETIC_3 )),
116 : :
117 : : aLevelFT(this, SW_RES(LBL_LEVEL )),
118 : : aLevelED(this, SW_RES(SL_LEVEL )),
119 : : aMainEntryCB(this, SW_RES(CB_MAIN_ENTRY )),
120 : : aApplyToAllCB(this,SW_RES(CB_APPLY_TO_ALL)),
121 : : aSearchCaseSensitiveCB(this, SW_RES(CB_CASESENSITIVE )),
122 : : aSearchCaseWordOnlyCB(this, SW_RES(CB_WORDONLY )),
123 : :
124 : :
125 : : aOKBT(this, SW_RES(BT_OK )),
126 : : aCancelBT(this, SW_RES(BT_CANCEL )),
127 : : aHelpBT(this, SW_RES(BT_HELP )),
128 : : aDelBT(this, SW_RES(BT_DEL )),
129 : :
130 : : aPrevSameBT(this,SW_RES(BT_PREVSAME)),
131 : : aNextSameBT(this,SW_RES(BT_NXTSAME)),
132 : : aPrevBT(this, SW_RES(BT_PREV )),
133 : : aNextBT(this, SW_RES(BT_NXT )),
134 : :
135 : : nOptionsId( _nOptionsId ),
136 : : bDel(sal_False),
137 : : bNewMark(bNewDlg),
138 : : bSelected(sal_False),
139 : :
140 : : bPhoneticED0_ChangedByUser(sal_False),
141 : : bPhoneticED1_ChangedByUser(sal_False),
142 : : bPhoneticED2_ChangedByUser(sal_False),
143 : : nLangForPhoneticReading(2052),
144 : : bIsPhoneticReadingEnabled(sal_False),
145 : : xExtendedIndexEntrySupplier(NULL),
146 : : pTOXMgr(0),
147 : 0 : pSh(&rWrtShell)
148 : : {
149 : 0 : aNewBT.SetAccessibleRelationMemberOf(&aIndexFL);
150 : :
151 : 0 : if( SvtCJKOptions().IsCJKFontEnabled() )
152 : : {
153 : 0 : uno::Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
154 : :
155 : : xExtendedIndexEntrySupplier =
156 : : uno::Reference< i18n::XExtendedIndexEntrySupplier > (
157 : 0 : xMSF->createInstance( C2U("com.sun.star.i18n.IndexEntrySupplier") ),
158 : 0 : uno::UNO_QUERY );
159 : : }
160 : :
161 : 0 : SetStyle(GetStyle()|WB_DIALOGCONTROL);
162 : 0 : FreeResource();
163 : 0 : aOKBT .SetHelpId(HID_INSERT_IDX_MRK_OK );
164 : 0 : aCancelBT .SetHelpId(HID_INSERT_IDX_MRK_CLOSE );
165 : 0 : aDelBT .SetHelpId(HID_INSERT_IDX_MRK_DELETE );
166 : 0 : aNewBT .SetHelpId(HID_INSERT_IDX_MRK_NEW );
167 : 0 : aPrevBT .SetHelpId(HID_INSERT_IDX_MRK_PREV );
168 : 0 : aPrevSameBT .SetHelpId(HID_INSERT_IDX_MRK_PREV_SAME );
169 : 0 : aNextBT .SetHelpId(HID_INSERT_IDX_MRK_NEXT );
170 : 0 : aNextSameBT .SetHelpId(HID_INSERT_IDX_MRK_NEXT_SAME );
171 : 0 : aTypeDCB .SetHelpId(HID_INSERT_IDX_MRK_TYPE );
172 : 0 : aEntryED .SetHelpId(HID_INSERT_IDX_MRK_ENTRY );
173 : 0 : aKeyDCB .SetHelpId(HID_INSERT_IDX_MRK_PRIM_KEY );
174 : 0 : aKey2DCB .SetHelpId(HID_INSERT_IDX_MRK_SEC_KEY );
175 : 0 : aLevelED .SetHelpId(HID_INSERT_IDX_MRK_LEVEL );
176 : 0 : aMainEntryCB .SetHelpId(HID_INSERT_IDX_MRK_MAIN_ENTRY);
177 : 0 : aApplyToAllCB .SetHelpId(HID_INSERT_IDX_MRK_APPLY_ALL );
178 : 0 : aPhoneticED0 .SetHelpId(HID_INSERT_IDX_MRK_PHONETIC_READING );
179 : 0 : aPhoneticED1 .SetHelpId(HID_INSERT_IDX_MRK_PHONETIC_READING );
180 : 0 : aPhoneticED2 .SetHelpId(HID_INSERT_IDX_MRK_PHONETIC_READING );
181 : :
182 : 0 : aSearchCaseSensitiveCB.SetHelpId( HID_INSERT_IDX_MRK_SRCH_CASESENSITIVE );
183 : 0 : aSearchCaseWordOnlyCB.SetHelpId( HID_INSERT_IDX_MRK_SRCH_WORDONLY );
184 : :
185 : :
186 : 0 : GetParent()->SetText( SW_RESSTR( bNewMark ? STR_IDXMRK_INSERT : STR_IDXMRK_EDIT));
187 : :
188 : 0 : aDelBT.SetClickHdl(LINK(this,SwIndexMarkDlg, DelHdl));
189 : 0 : aPrevBT.SetClickHdl(LINK(this,SwIndexMarkDlg, PrevHdl));
190 : 0 : aPrevSameBT.SetClickHdl(LINK(this,SwIndexMarkDlg, PrevSameHdl));
191 : 0 : aNextBT.SetClickHdl(LINK(this,SwIndexMarkDlg, NextHdl));
192 : 0 : aNextSameBT.SetClickHdl(LINK(this,SwIndexMarkDlg, NextSameHdl));
193 : 0 : aTypeDCB.SetSelectHdl(LINK(this,SwIndexMarkDlg, ModifyHdl));
194 : 0 : aKeyDCB.SetModifyHdl(LINK(this,SwIndexMarkDlg, KeyDCBModifyHdl));
195 : 0 : aKey2DCB.SetModifyHdl(LINK(this,SwIndexMarkDlg, KeyDCBModifyHdl));
196 : 0 : aOKBT.SetClickHdl(LINK(this,SwIndexMarkDlg, InsertHdl));
197 : 0 : aCancelBT.SetClickHdl(LINK(this,SwIndexMarkDlg, CloseHdl));
198 : 0 : aEntryED.SetModifyHdl(LINK(this,SwIndexMarkDlg, ModifyHdl));
199 : 0 : aNewBT.SetClickHdl(LINK(this, SwIndexMarkDlg, NewUserIdxHdl));
200 : 0 : aApplyToAllCB.SetClickHdl(LINK(this, SwIndexMarkDlg, SearchTypeHdl));
201 : 0 : aPhoneticED0.SetModifyHdl(LINK(this,SwIndexMarkDlg, PhoneticEDModifyHdl));
202 : 0 : aPhoneticED1.SetModifyHdl(LINK(this,SwIndexMarkDlg, PhoneticEDModifyHdl));
203 : 0 : aPhoneticED2.SetModifyHdl(LINK(this,SwIndexMarkDlg, PhoneticEDModifyHdl));
204 : :
205 : 0 : if(bNewMark)
206 : : {
207 : 0 : aDelBT.Hide();
208 : 0 : ImageList aTempList( SW_RES( IMG_NAVI_ENTRYBMP ) );
209 : 0 : aNewBT.SetModeImage( aTempList.GetImage( SID_SW_START + CONTENT_TYPE_INDEX ) );
210 : : }
211 : : else
212 : : {
213 : 0 : aNewBT.Hide();
214 : 0 : OKButton aTmp(this, WB_HIDE);
215 : 0 : aOKBT.SetText( aTmp.GetText() );
216 : : }
217 : :
218 : 0 : aEntryED.GrabFocus();
219 : 0 : }
220 : :
221 : : /*--------------------------------------------------------------------
222 : : Description: Newly initialise controls with the new selection
223 : : --------------------------------------------------------------------*/
224 : 0 : void SwIndexMarkDlg::InitControls()
225 : : {
226 : : OSL_ENSURE(pSh && pTOXMgr, "no shell?");
227 : : // contents index
228 : 0 : const SwTOXType* pType = pTOXMgr->GetTOXType(TOX_CONTENT, 0);
229 : : OSL_ENSURE(pType, "Kein Verzeichnistyp !!");
230 : 0 : String sTmpTypeSelection;
231 : 0 : if(aTypeDCB.GetSelectEntryCount())
232 : 0 : sTmpTypeSelection = aTypeDCB.GetSelectEntry();
233 : 0 : aTypeDCB.Clear();
234 : 0 : aTypeDCB.InsertEntry(pType->GetTypeName());
235 : :
236 : : // keyword index
237 : 0 : pType = pTOXMgr->GetTOXType(TOX_INDEX, 0);
238 : : OSL_ENSURE(pType, "Kein Verzeichnistyp !!");
239 : 0 : aTypeDCB.InsertEntry(pType->GetTypeName());
240 : :
241 : : // user index
242 : 0 : sal_uInt16 nCount = pSh->GetTOXTypeCount(TOX_USER);
243 : : sal_uInt16 i;
244 : 0 : for( i = 0; i < nCount; ++i )
245 : 0 : aTypeDCB.InsertEntry( pSh->GetTOXType(TOX_USER, i)->GetTypeName() );
246 : :
247 : : // read keywords primary
248 : 0 : std::vector<String> aArr;
249 : 0 : nCount = pSh->GetTOIKeys( TOI_PRIMARY, aArr );
250 : 0 : std::sort(aArr.begin(), aArr.end());
251 : 0 : for (std::vector<String>::iterator it = aArr.begin(); it != aArr.end(); ++it)
252 : 0 : aKeyDCB.InsertEntry( *it );
253 : :
254 : : // read keywords secondary
255 : 0 : nCount = pSh->GetTOIKeys( TOI_SECONDARY, aArr );
256 : 0 : std::sort(aArr.begin(), aArr.end());
257 : 0 : for (std::vector<String>::iterator it = aArr.begin(); it != aArr.end(); ++it)
258 : 0 : aKey2DCB.InsertEntry( *it );
259 : :
260 : 0 : UpdateLanguageDependenciesForPhoneticReading();
261 : :
262 : : // current entry
263 : 0 : const SwTOXMark* pMark = pTOXMgr->GetCurTOXMark();
264 : 0 : if( pMark && !bNewMark)
265 : : {
266 : : // Controls-Handling
267 : :
268 : : // onyl if there are more than one
269 : : // if equal it lands at the same entry
270 : 0 : pSh->SttCrsrMove();
271 : :
272 : : const SwTOXMark* pMoveMark;
273 : 0 : sal_Bool bShow = sal_False;
274 : :
275 : 0 : pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_PRV );
276 : 0 : if( pMoveMark != pMark )
277 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_NXT ), bShow = sal_True;
278 : 0 : aPrevBT.Enable( pMoveMark != pMark );
279 : 0 : pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_NXT );
280 : 0 : if( pMoveMark != pMark )
281 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_PRV ), bShow = sal_True;
282 : 0 : aNextBT.Enable( pMoveMark != pMark );
283 : 0 : if( bShow )
284 : : {
285 : 0 : aPrevBT.Show();
286 : 0 : aNextBT.Show();
287 : 0 : bShow = sal_False;
288 : : }
289 : :
290 : 0 : pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
291 : 0 : if( pMoveMark != pMark )
292 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT ), bShow = sal_True;
293 : 0 : aPrevSameBT.Enable( pMoveMark != pMark );
294 : 0 : pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
295 : 0 : if( pMoveMark != pMark )
296 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV ), bShow = sal_True;
297 : 0 : aNextSameBT.Enable( pMoveMark != pMark );
298 : 0 : if( bShow )
299 : : {
300 : 0 : aNextSameBT.Show();
301 : 0 : aPrevSameBT.Show();
302 : : }
303 : 0 : pSh->EndCrsrMove();
304 : :
305 : 0 : aTypeFT.Show();
306 : :
307 : 0 : aTypeDCB.Enable(sal_False);
308 : 0 : aTypeFT.Enable(sal_False);
309 : :
310 : 0 : UpdateDialog();
311 : : }
312 : : else
313 : : { // display current selection (first element) ????
314 : 0 : sal_uInt16 nCnt = pSh->GetCrsrCnt();
315 : 0 : if (nCnt < 2)
316 : : {
317 : 0 : bSelected = !pSh->HasSelection();
318 : 0 : aOrgStr = pSh->GetView().GetSelectionTextParam(sal_True, sal_False);
319 : 0 : aEntryED.SetText(aOrgStr);
320 : :
321 : : //to include all equal entries may only be allowed in the body and even there
322 : : //only when a simple selection exists
323 : 0 : const sal_uInt16 nFrmType = pSh->GetFrmType(0,sal_True);
324 : 0 : aApplyToAllCB.Show();
325 : 0 : aSearchCaseSensitiveCB.Show();
326 : 0 : aSearchCaseWordOnlyCB.Show();
327 : 0 : aApplyToAllCB.Enable(0 != aOrgStr.Len() &&
328 : 0 : 0 == (nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FLY_ANY )));
329 : 0 : SearchTypeHdl(&aApplyToAllCB);
330 : : }
331 : :
332 : : // index type is default
333 : 0 : if( sTmpTypeSelection.Len() &&
334 : 0 : LISTBOX_ENTRY_NOTFOUND != aTypeDCB.GetEntryPos( sTmpTypeSelection ) )
335 : 0 : aTypeDCB.SelectEntry(sTmpTypeSelection);
336 : : else
337 : 0 : aTypeDCB.SelectEntry(aTypeDCB.GetEntry(nTypePos));
338 : 0 : ModifyHdl(&aTypeDCB);
339 : 0 : }
340 : 0 : }
341 : :
342 : 0 : void SwIndexMarkDlg::UpdateLanguageDependenciesForPhoneticReading()
343 : : {
344 : : //no phonetic reading if no global cjk support
345 : 0 : if( !xExtendedIndexEntrySupplier.is() )
346 : : {
347 : 0 : bIsPhoneticReadingEnabled = sal_False;
348 : 0 : return;
349 : : }
350 : 0 : bIsPhoneticReadingEnabled = sal_True;
351 : :
352 : : //get the current language
353 : 0 : if(!bNewMark) //if dialog is opened to iterate existing marks
354 : : {
355 : : OSL_ENSURE(pTOXMgr, "need TOXMgr");
356 : 0 : if(!pTOXMgr)
357 : 0 : return;
358 : 0 : SwTOXMark* pMark = pTOXMgr->GetCurTOXMark();
359 : : OSL_ENSURE(pMark, "need current SwTOXMark");
360 : 0 : if(!pMark)
361 : 0 : return;
362 : 0 : SwTxtTOXMark* pTxtTOXMark = pMark->GetTxtTOXMark();
363 : : OSL_ENSURE(pTxtTOXMark, "need current SwTxtTOXMark");
364 : 0 : if(!pTxtTOXMark)
365 : 0 : return;
366 : 0 : const SwTxtNode* pTxtNode = pTxtTOXMark->GetpTxtNd();
367 : : OSL_ENSURE(pTxtNode, "need current SwTxtNode");
368 : 0 : if(!pTxtNode)
369 : 0 : return;
370 : 0 : xub_StrLen nTextIndex = *pTxtTOXMark->GetStart();
371 : 0 : nLangForPhoneticReading = pTxtNode->GetLang( nTextIndex );
372 : : }
373 : : else //if dialog is opened to create a new mark
374 : : {
375 : 0 : sal_uInt16 nScriptType = pSh->GetScriptType();
376 : : sal_uInt16 nWhich;
377 : 0 : switch(nScriptType)
378 : : {
379 : 0 : case SCRIPTTYPE_ASIAN: nWhich = RES_CHRATR_CJK_LANGUAGE; break;
380 : 0 : case SCRIPTTYPE_COMPLEX:nWhich = RES_CHRATR_CTL_LANGUAGE; break;
381 : 0 : default:nWhich = RES_CHRATR_LANGUAGE; break;
382 : : }
383 : 0 : SfxItemSet aLangSet(pSh->GetAttrPool(), nWhich, nWhich);
384 : 0 : pSh->GetCurAttr(aLangSet);
385 : 0 : nLangForPhoneticReading = ((const SvxLanguageItem&)aLangSet.Get(nWhich)).GetLanguage();
386 : : }
387 : :
388 : : }
389 : :
390 : 0 : String SwIndexMarkDlg::GetDefaultPhoneticReading( const String& rText )
391 : : {
392 : 0 : if( !bIsPhoneticReadingEnabled )
393 : 0 : return aEmptyStr;
394 : :
395 : 0 : lang::Locale aLocale( SvxCreateLocale( LanguageType( nLangForPhoneticReading ) ) );
396 : 0 : return xExtendedIndexEntrySupplier->getPhoneticCandidate(rText, aLocale);
397 : : }
398 : :
399 : : /* --------------------------------------------------
400 : : Change the content of aEntryED if text is selected
401 : : --------------------------------------------------*/
402 : 0 : void SwIndexMarkDlg::Activate()
403 : : {
404 : : // display current selection (first element) ????
405 : 0 : if(bNewMark)
406 : : {
407 : 0 : sal_uInt16 nCnt = pSh->GetCrsrCnt();
408 : 0 : if (nCnt < 2)
409 : : {
410 : 0 : bSelected = !pSh->HasSelection();
411 : 0 : aOrgStr = pSh->GetView().GetSelectionTextParam(sal_True, sal_False);
412 : 0 : aEntryED.SetText(aOrgStr);
413 : :
414 : : //to include all equal entries may only be allowed in the body and even there
415 : : //only when a simple selection exists
416 : 0 : const sal_uInt16 nFrmType = pSh->GetFrmType(0,sal_True);
417 : 0 : aApplyToAllCB.Show();
418 : 0 : aSearchCaseSensitiveCB.Show();
419 : 0 : aSearchCaseWordOnlyCB.Show();
420 : 0 : aApplyToAllCB.Enable(0 != aOrgStr.Len() &&
421 : 0 : 0 == (nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FLY_ANY )));
422 : 0 : SearchTypeHdl(&aApplyToAllCB);
423 : : }
424 : 0 : ModifyHdl(&aTypeDCB);
425 : : }
426 : 0 : }
427 : :
428 : : /*--------------------------------------------------------------------
429 : : Description: evaluate Ok-Button
430 : : --------------------------------------------------------------------*/
431 : 0 : void SwIndexMarkDlg::Apply()
432 : : {
433 : 0 : InsertUpdate();
434 : 0 : if(bSelected)
435 : 0 : pSh->ResetSelect(0, sal_False);
436 : 0 : }
437 : :
438 : : /*--------------------------------------------------------------------
439 : : Description: apply changes
440 : : --------------------------------------------------------------------*/
441 : 0 : void SwIndexMarkDlg::InsertUpdate()
442 : : {
443 : 0 : pSh->StartUndo(bDel ? UNDO_INDEX_ENTRY_DELETE : UNDO_INDEX_ENTRY_INSERT);
444 : 0 : pSh->StartAllAction();
445 : :
446 : 0 : SwRewriter aRewriter;
447 : :
448 : 0 : if( bNewMark )
449 : : {
450 : 0 : InsertMark();
451 : :
452 : 0 : if ( pTOXMgr->GetCurTOXMark())
453 : 0 : aRewriter.AddRule(UndoArg1, pTOXMgr->GetCurTOXMark()->GetText());
454 : : }
455 : 0 : else if( !pSh->HasReadonlySel() )
456 : : {
457 : 0 : if ( pTOXMgr->GetCurTOXMark())
458 : : aRewriter.AddRule(UndoArg1,
459 : 0 : pTOXMgr->GetCurTOXMark()->GetText());
460 : :
461 : 0 : if( bDel )
462 : 0 : pTOXMgr->DeleteTOXMark();
463 : 0 : else if( pTOXMgr->GetCurTOXMark() )
464 : 0 : UpdateMark();
465 : : }
466 : :
467 : 0 : pSh->EndAllAction();
468 : 0 : pSh->EndUndo(bDel ? UNDO_INDEX_ENTRY_DELETE : UNDO_INDEX_ENTRY_INSERT);
469 : :
470 : 0 : if((nTypePos = aTypeDCB.GetEntryPos(aTypeDCB.GetSelectEntry())) == LISTBOX_ENTRY_NOTFOUND)
471 : 0 : nTypePos = 0;
472 : :
473 : 0 : nKey1Pos = aKeyDCB.GetEntryPos(aKeyDCB.GetText());
474 : 0 : nKey2Pos = aKey2DCB.GetEntryPos(aKey2DCB.GetText());
475 : 0 : }
476 : :
477 : : /*--------------------------------------------------------------------
478 : : Description: insert mark
479 : : --------------------------------------------------------------------*/
480 : 0 : static void lcl_SelectSameStrings(SwWrtShell& rSh, sal_Bool bWordOnly, sal_Bool bCaseSensitive)
481 : : {
482 : 0 : rSh.Push();
483 : :
484 : : SearchOptions aSearchOpt(
485 : : SearchAlgorithms_ABSOLUTE,
486 : : ( bWordOnly ? SearchFlags::NORM_WORD_ONLY : 0 ),
487 : : rSh.GetSelTxt(), OUString(),
488 : 0 : SvxCreateLocale( GetAppLanguage() ),
489 : : 0, 0, 0,
490 : : (bCaseSensitive
491 : : ? 0
492 : 0 : : TransliterationModules_IGNORE_CASE) );
493 : :
494 : 0 : rSh.ClearMark();
495 : : sal_Bool bCancel;
496 : :
497 : : //todo/mba: assuming that notes should not be searched
498 : 0 : sal_Bool bSearchInNotes = sal_False;
499 : : rSh.Find( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END, bCancel,
500 : 0 : (FindRanges)(FND_IN_SELALL|FND_IN_BODYONLY), sal_False );
501 : 0 : }
502 : :
503 : :
504 : 0 : void SwIndexMarkDlg::InsertMark()
505 : : {
506 : 0 : sal_uInt16 nPos = aTypeDCB.GetEntryPos(aTypeDCB.GetSelectEntry());
507 : : TOXTypes eType = nPos == POS_CONTENT ? TOX_CONTENT :
508 : 0 : nPos == POS_INDEX ? TOX_INDEX : TOX_USER;
509 : :
510 : 0 : SwTOXMarkDescription aDesc(eType);
511 : :
512 : 0 : sal_uInt16 nLevel = (sal_uInt16)aLevelED.Denormalize(aLevelED.GetValue());
513 : 0 : switch(nPos)
514 : : {
515 : 0 : case POS_CONTENT : break;
516 : : case POS_INDEX: // keyword index mark
517 : : {
518 : 0 : UpdateKeyBoxes();
519 : 0 : String aPrim(aKeyDCB.GetText());
520 : 0 : String aSec(aKey2DCB.GetText());
521 : 0 : aDesc.SetPrimKey(aPrim);
522 : 0 : aDesc.SetSecKey(aSec);
523 : 0 : aDesc.SetMainEntry(aMainEntryCB.IsChecked());
524 : 0 : aDesc.SetPhoneticReadingOfAltStr(aPhoneticED0.GetText());
525 : 0 : aDesc.SetPhoneticReadingOfPrimKey(aPhoneticED1.GetText());
526 : 0 : aDesc.SetPhoneticReadingOfSecKey(aPhoneticED2.GetText());
527 : : }
528 : 0 : break;
529 : : default: // Userdefined index mark
530 : : {
531 : 0 : String aName(aTypeDCB.GetSelectEntry());
532 : 0 : aDesc.SetTOUName(aName);
533 : : }
534 : : }
535 : 0 : if (aOrgStr != aEntryED.GetText())
536 : 0 : aDesc.SetAltStr(aEntryED.GetText());
537 : 0 : sal_Bool bApplyAll = aApplyToAllCB.IsChecked();
538 : 0 : sal_Bool bWordOnly = aSearchCaseWordOnlyCB.IsChecked();
539 : 0 : sal_Bool bCaseSensitive = aSearchCaseSensitiveCB.IsChecked();
540 : :
541 : 0 : pSh->StartAllAction();
542 : : // all equal strings have to be selected here so that the
543 : : // entry is apllied to all equal strings
544 : 0 : if(bApplyAll)
545 : : {
546 : 0 : lcl_SelectSameStrings(*pSh, bWordOnly, bCaseSensitive);
547 : : }
548 : 0 : aDesc.SetLevel(nLevel);
549 : 0 : SwTOXMgr aMgr(pSh);
550 : 0 : aMgr.InsertTOXMark(aDesc);
551 : 0 : if(bApplyAll)
552 : 0 : pSh->Pop(sal_False);
553 : :
554 : 0 : pSh->EndAllAction();
555 : 0 : }
556 : :
557 : : /*--------------------------------------------------------------------
558 : : Description: update mark
559 : : --------------------------------------------------------------------*/
560 : 0 : void SwIndexMarkDlg::UpdateMark()
561 : : {
562 : 0 : String aAltText(aEntryED.GetText());
563 : 0 : String* pAltText = aOrgStr != aEntryED.GetText() ? &aAltText : 0;
564 : : //empty alternative texts are not allowed
565 : 0 : if(pAltText && !pAltText->Len())
566 : 0 : return;
567 : :
568 : 0 : UpdateKeyBoxes();
569 : :
570 : 0 : sal_uInt16 nPos = aTypeDCB.GetEntryPos(aTypeDCB.GetSelectEntry());
571 : 0 : TOXTypes eType = TOX_USER;
572 : 0 : if(POS_CONTENT == nPos)
573 : 0 : eType = TOX_CONTENT;
574 : 0 : else if(POS_INDEX == nPos)
575 : 0 : eType = TOX_INDEX;
576 : :
577 : 0 : SwTOXMarkDescription aDesc(eType);
578 : 0 : aDesc.SetLevel( static_cast< int >(aLevelED.GetValue()) );
579 : 0 : if(pAltText)
580 : 0 : aDesc.SetAltStr(*pAltText);
581 : :
582 : 0 : String aPrim(aKeyDCB.GetText());
583 : 0 : if(aPrim.Len())
584 : 0 : aDesc.SetPrimKey(aPrim);
585 : 0 : String aSec(aKey2DCB.GetText());
586 : 0 : if(aSec.Len())
587 : 0 : aDesc.SetSecKey(aSec);
588 : :
589 : 0 : if(eType == TOX_INDEX)
590 : : {
591 : 0 : aDesc.SetPhoneticReadingOfAltStr(aPhoneticED0.GetText());
592 : 0 : aDesc.SetPhoneticReadingOfPrimKey(aPhoneticED1.GetText());
593 : 0 : aDesc.SetPhoneticReadingOfSecKey(aPhoneticED2.GetText());
594 : : }
595 : 0 : aDesc.SetMainEntry(aMainEntryCB.IsVisible() && aMainEntryCB.IsChecked());
596 : 0 : pTOXMgr->UpdateTOXMark(aDesc);
597 : : }
598 : :
599 : : /*--------------------------------------------------------------------
600 : : Description: insert new keys
601 : : --------------------------------------------------------------------*/
602 : 0 : void SwIndexMarkDlg::UpdateKeyBoxes()
603 : : {
604 : 0 : String aKey(aKeyDCB.GetText());
605 : 0 : sal_uInt16 nPos = aKeyDCB.GetEntryPos(aKey);
606 : :
607 : 0 : if(nPos == LISTBOX_ENTRY_NOTFOUND && aKey.Len() > 0)
608 : : { // create new key
609 : 0 : aKeyDCB.InsertEntry(aKey);
610 : : }
611 : :
612 : 0 : aKey = aKey2DCB.GetText();
613 : 0 : nPos = aKey2DCB.GetEntryPos(aKey);
614 : :
615 : 0 : if(nPos == LISTBOX_ENTRY_NOTFOUND && aKey.Len() > 0)
616 : : { // create new key
617 : 0 : aKey2DCB.InsertEntry(aKey);
618 : 0 : }
619 : 0 : }
620 : :
621 : 0 : class SwNewUserIdxDlg : public ModalDialog
622 : : {
623 : : OKButton aOKPB;
624 : : CancelButton aCancelPB;
625 : : HelpButton aHelpPB;
626 : : FixedLine aNameFL;
627 : : FixedText aNameFT;
628 : : Edit aNameED;
629 : :
630 : : SwIndexMarkDlg* pDlg;
631 : :
632 : : DECL_LINK( ModifyHdl, Edit*);
633 : :
634 : : public:
635 : 0 : SwNewUserIdxDlg(SwIndexMarkDlg* pParent) :
636 : : ModalDialog(pParent, SW_RES(DLG_NEW_USER_IDX)),
637 : : aOKPB(this, SW_RES( PB_OK )),
638 : : aCancelPB(this, SW_RES( PB_CANCEL )),
639 : : aHelpPB(this, SW_RES( PB_HELP )),
640 : : aNameFL(this, SW_RES( FL_NAME )),
641 : : aNameFT(this, SW_RES( FT_NAME )),
642 : : aNameED(this, SW_RES( ED_NAME )),
643 : 0 : pDlg(pParent)
644 : : {
645 : 0 : FreeResource();
646 : 0 : aNameED.SetModifyHdl(LINK(this, SwNewUserIdxDlg, ModifyHdl));
647 : 0 : aOKPB.Enable(sal_False);
648 : 0 : aNameED.GrabFocus();
649 : 0 : }
650 : :
651 : : virtual void Apply();
652 : 0 : String GetName(){return aNameED.GetText();}
653 : : };
654 : 0 : void SwNewUserIdxDlg::Apply()
655 : : {
656 : 0 : }
657 : :
658 : 0 : IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, Edit*, pEdit)
659 : : {
660 : 0 : aOKPB.Enable(pEdit->GetText().Len() && !pDlg->IsTOXType(pEdit->GetText()));
661 : 0 : return 0;
662 : : }
663 : :
664 : 0 : IMPL_LINK_NOARG(SwIndexMarkDlg, NewUserIdxHdl)
665 : : {
666 : 0 : SwNewUserIdxDlg* pDlg = new SwNewUserIdxDlg(this);
667 : 0 : if(RET_OK == pDlg->Execute())
668 : : {
669 : 0 : String sNewName(pDlg->GetName());
670 : 0 : aTypeDCB.InsertEntry(sNewName);
671 : 0 : aTypeDCB.SelectEntry(sNewName);
672 : : }
673 : 0 : delete pDlg;
674 : 0 : return 0;
675 : : }
676 : :
677 : 0 : IMPL_LINK( SwIndexMarkDlg, SearchTypeHdl, CheckBox*, pBox)
678 : : {
679 : 0 : sal_Bool bEnable = pBox->IsChecked() && pBox->IsEnabled();
680 : 0 : aSearchCaseWordOnlyCB.Enable(bEnable);
681 : 0 : aSearchCaseSensitiveCB.Enable(bEnable);
682 : 0 : return 0;
683 : : }
684 : :
685 : 0 : IMPL_LINK( SwIndexMarkDlg, InsertHdl, Button *, pButton )
686 : : {
687 : 0 : Apply();
688 : : //close the dialog if only one entry is available
689 : 0 : if(!bNewMark && !aPrevBT.IsVisible() && !aNextBT.IsVisible())
690 : 0 : CloseHdl(pButton);
691 : 0 : return 0;
692 : : }
693 : :
694 : 0 : IMPL_LINK_NOARG(SwIndexMarkDlg, CloseHdl)
695 : : {
696 : 0 : if(bNewMark)
697 : : {
698 : 0 : sal_uInt16 nSlot = FN_INSERT_IDX_ENTRY_DLG;
699 : : SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot,
700 : 0 : SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD);
701 : : }
702 : : else
703 : : {
704 : 0 : ((SwIndexMarkModalDlg*)GetParent())->EndDialog(RET_CANCEL);
705 : : }
706 : 0 : return 0;
707 : : }
708 : :
709 : : /*--------------------------------------------------------------------
710 : : Description: select index type only when inserting
711 : : --------------------------------------------------------------------*/
712 : 0 : IMPL_LINK( SwIndexMarkDlg, ModifyHdl, ListBox *, pBox )
713 : : {
714 : 0 : if(&aTypeDCB == pBox)
715 : : {
716 : : // set index type
717 : 0 : sal_uInt16 nPos = aTypeDCB.GetEntryPos(aTypeDCB.GetSelectEntry());
718 : 0 : sal_Bool bLevelEnable = sal_False,
719 : 0 : bKeyEnable = sal_False,
720 : 0 : bSetKey2 = sal_False,
721 : 0 : bKey2Enable = sal_False,
722 : 0 : bEntryHasText = sal_False,
723 : 0 : bKey1HasText = sal_False,
724 : 0 : bKey2HasText = sal_False;
725 : 0 : if(nPos == POS_INDEX)
726 : : {
727 : 0 : if(aEntryED.GetText().Len())
728 : 0 : bEntryHasText = sal_True;
729 : 0 : aPhoneticED0.SetText(GetDefaultPhoneticReading(aEntryED.GetText()));
730 : :
731 : 0 : bKeyEnable = sal_True;
732 : 0 : aKeyDCB.SetText(aKeyDCB.GetEntry(nKey1Pos));
733 : 0 : aPhoneticED1.SetText(GetDefaultPhoneticReading(aKeyDCB.GetText()));
734 : 0 : if(aKeyDCB.GetText().Len() > 0)
735 : : {
736 : 0 : bKey1HasText = bSetKey2 = bKey2Enable = sal_True;
737 : 0 : aKey2DCB.SetText(aKey2DCB.GetEntry(nKey2Pos));
738 : 0 : aPhoneticED2.SetText(GetDefaultPhoneticReading(aKey2DCB.GetText()));
739 : 0 : if(aKey2DCB.GetText().Len())
740 : 0 : bKey2HasText = sal_True;
741 : : }
742 : : }
743 : : else
744 : : {
745 : 0 : bLevelEnable = sal_True;
746 : 0 : aLevelED.SetMax(MAXLEVEL);
747 : 0 : aLevelED.SetValue(aLevelED.Normalize(0));
748 : 0 : bSetKey2 = sal_True;
749 : : }
750 : 0 : aLevelFT.Show(bLevelEnable);
751 : 0 : aLevelED.Show(bLevelEnable);
752 : 0 : aMainEntryCB.Show(nPos == POS_INDEX);
753 : :
754 : 0 : aKeyFT.Enable(bKeyEnable);
755 : 0 : aKeyDCB.Enable(bKeyEnable);
756 : 0 : if ( bSetKey2 )
757 : : {
758 : 0 : aKey2DCB.Enable(bKey2Enable);
759 : 0 : aKey2FT.Enable(bKey2Enable);
760 : : }
761 : 0 : aPhoneticFT0.Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
762 : 0 : aPhoneticED0.Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
763 : 0 : aPhoneticFT1.Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
764 : 0 : aPhoneticED1.Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
765 : 0 : aPhoneticFT2.Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
766 : 0 : aPhoneticED2.Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
767 : : }
768 : : else //aEntryED !!aEntryED is not a ListBox but a Edit
769 : : {
770 : 0 : sal_Bool bHasText = (aEntryED.GetText().Len()>0);
771 : 0 : if(!bHasText)
772 : : {
773 : 0 : aPhoneticED0.SetText(aEmptyStr);
774 : 0 : bPhoneticED0_ChangedByUser = sal_False;
775 : : }
776 : 0 : else if(!bPhoneticED0_ChangedByUser)
777 : 0 : aPhoneticED0.SetText(GetDefaultPhoneticReading(aEntryED.GetText()));
778 : :
779 : 0 : aPhoneticFT0.Enable(bHasText&&bIsPhoneticReadingEnabled);
780 : 0 : aPhoneticED0.Enable(bHasText&&bIsPhoneticReadingEnabled);
781 : : }
782 : 0 : aOKBT.Enable(!pSh->HasReadonlySel() &&
783 : 0 : (aEntryED.GetText().Len() || pSh->GetCrsrCnt(sal_False)));
784 : 0 : return 0;
785 : : }
786 : :
787 : 0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkDlg, NextHdl)
788 : : {
789 : 0 : InsertUpdate();
790 : 0 : pTOXMgr->NextTOXMark();
791 : 0 : UpdateDialog();
792 : 0 : return 0;
793 : : }
794 : 0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkDlg, NextHdl)
795 : :
796 : 0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkDlg, NextSameHdl)
797 : : {
798 : 0 : InsertUpdate();
799 : 0 : pTOXMgr->NextTOXMark(sal_True);
800 : 0 : UpdateDialog();
801 : 0 : return 0;
802 : : }
803 : 0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkDlg, NextSameHdl)
804 : :
805 : 0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkDlg, PrevHdl)
806 : : {
807 : 0 : InsertUpdate();
808 : 0 : pTOXMgr->PrevTOXMark();
809 : 0 : UpdateDialog();
810 : 0 : return 0;
811 : : }
812 : 0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkDlg, PrevHdl)
813 : :
814 : 0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkDlg, PrevSameHdl)
815 : : {
816 : 0 : InsertUpdate();
817 : 0 : pTOXMgr->PrevTOXMark(sal_True);
818 : 0 : UpdateDialog();
819 : :
820 : 0 : return 0;
821 : : }
822 : 0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkDlg, PrevSameHdl)
823 : :
824 : 0 : IMPL_LINK_NOARG(SwIndexMarkDlg, DelHdl)
825 : : {
826 : 0 : bDel = sal_True;
827 : 0 : InsertUpdate();
828 : 0 : bDel = sal_False;
829 : :
830 : 0 : if(pTOXMgr->GetCurTOXMark())
831 : 0 : UpdateDialog();
832 : : else
833 : : {
834 : 0 : CloseHdl(&aCancelBT);
835 : 0 : SfxViewFrame::Current()->GetBindings().Invalidate(FN_EDIT_IDX_ENTRY_DLG);
836 : : }
837 : 0 : return 0;
838 : : }
839 : :
840 : : /*--------------------------------------------------------------------
841 : : Description: renew dialog view
842 : : --------------------------------------------------------------------*/
843 : 0 : void SwIndexMarkDlg::UpdateDialog()
844 : : {
845 : : OSL_ENSURE(pSh && pTOXMgr, "no shell?");
846 : 0 : SwTOXMark* pMark = pTOXMgr->GetCurTOXMark();
847 : : OSL_ENSURE(pMark, "no current marker");
848 : 0 : if(!pMark)
849 : 0 : return;
850 : :
851 : 0 : ViewShell::SetCareWin( GetParent() );
852 : :
853 : 0 : aOrgStr = pMark->GetText();
854 : 0 : aEntryED.SetText(aOrgStr);
855 : :
856 : : // set index type
857 : 0 : sal_Bool bLevelEnable = sal_True,
858 : 0 : bKeyEnable = sal_False,
859 : 0 : bKey2Enable = sal_False,
860 : 0 : bEntryHasText = sal_False,
861 : 0 : bKey1HasText = sal_False,
862 : 0 : bKey2HasText = sal_False;
863 : :
864 : 0 : TOXTypes eCurType = pMark->GetTOXType()->GetType();
865 : 0 : if(TOX_INDEX == eCurType)
866 : : {
867 : 0 : bLevelEnable = sal_False;
868 : 0 : bKeyEnable = sal_True;
869 : 0 : bKey1HasText = bKey2Enable = 0 != pMark->GetPrimaryKey().Len();
870 : 0 : bKey2HasText = 0 != pMark->GetSecondaryKey().Len();
871 : 0 : bEntryHasText = 0 != pMark->GetText().Len();
872 : 0 : aKeyDCB.SetText( pMark->GetPrimaryKey() );
873 : 0 : aKey2DCB.SetText( pMark->GetSecondaryKey() );
874 : 0 : aPhoneticED0.SetText( pMark->GetTextReading() );
875 : 0 : aPhoneticED1.SetText( pMark->GetPrimaryKeyReading() );
876 : 0 : aPhoneticED2.SetText( pMark->GetSecondaryKeyReading() );
877 : 0 : aMainEntryCB.Check(pMark->IsMainEntry());
878 : : }
879 : 0 : else if(TOX_CONTENT == eCurType || TOX_USER == eCurType)
880 : : {
881 : 0 : aLevelED.SetValue(aLevelED.Normalize(pMark->GetLevel()));
882 : : }
883 : 0 : aKeyFT.Enable(bKeyEnable);
884 : 0 : aKeyDCB.Enable(bKeyEnable);
885 : 0 : aLevelED.SetMax(MAXLEVEL);
886 : 0 : aLevelFT.Show(bLevelEnable);
887 : 0 : aLevelED.Show(bLevelEnable);
888 : 0 : aMainEntryCB.Show(!bLevelEnable);
889 : 0 : aKey2FT.Enable(bKey2Enable);
890 : 0 : aKey2DCB.Enable(bKey2Enable);
891 : :
892 : 0 : UpdateLanguageDependenciesForPhoneticReading();
893 : 0 : aPhoneticFT0.Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
894 : 0 : aPhoneticED0.Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
895 : 0 : aPhoneticFT1.Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
896 : 0 : aPhoneticED1.Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
897 : 0 : aPhoneticFT2.Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
898 : 0 : aPhoneticED2.Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
899 : :
900 : : // set index type
901 : 0 : aTypeDCB.SelectEntry(pMark->GetTOXType()->GetTypeName());
902 : :
903 : : // set Next - Prev - Buttons
904 : 0 : pSh->SttCrsrMove();
905 : 0 : if( aPrevBT.IsVisible() )
906 : : {
907 : 0 : const SwTOXMark* pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_PRV );
908 : 0 : if( pMoveMark != pMark )
909 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_NXT );
910 : 0 : aPrevBT.Enable( pMoveMark != pMark );
911 : 0 : pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_NXT );
912 : 0 : if( pMoveMark != pMark )
913 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_PRV );
914 : 0 : aNextBT.Enable( pMoveMark != pMark );
915 : : }
916 : :
917 : 0 : if( aPrevSameBT.IsVisible() )
918 : : {
919 : 0 : const SwTOXMark* pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
920 : 0 : if( pMoveMark != pMark )
921 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT );
922 : 0 : aPrevSameBT.Enable( pMoveMark != pMark );
923 : 0 : pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
924 : 0 : if( pMoveMark != pMark )
925 : 0 : pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV );
926 : 0 : aNextSameBT.Enable( pMoveMark != pMark );
927 : : }
928 : :
929 : 0 : sal_Bool bEnable = !pSh->HasReadonlySel();
930 : 0 : aOKBT.Enable( bEnable );
931 : 0 : aDelBT.Enable( bEnable );
932 : 0 : aEntryED.SetReadOnly( !bEnable );
933 : 0 : aLevelED.SetReadOnly( !bEnable );
934 : 0 : aKeyDCB.SetReadOnly( !bEnable );
935 : 0 : aKey2DCB.SetReadOnly( !bEnable );
936 : :
937 : 0 : pSh->SelectTxtAttr( RES_TXTATR_TOXMARK, pMark->GetTxtTOXMark() );
938 : : // we need the point at the start of the attribut
939 : 0 : pSh->SwapPam();
940 : :
941 : 0 : pSh->EndCrsrMove();
942 : : }
943 : :
944 : : /*--------------------------------------------------------------------
945 : : Remind whether the edit boxes for Phonetic reading are changed manually
946 : : --------------------------------------------------------------------*/
947 : 0 : IMPL_LINK( SwIndexMarkDlg, PhoneticEDModifyHdl, Edit *, pEdit )
948 : : {
949 : 0 : if(&aPhoneticED0 == pEdit)
950 : : {
951 : 0 : bPhoneticED0_ChangedByUser = pEdit->GetText().Len()>0;
952 : : }
953 : 0 : else if(&aPhoneticED1 == pEdit)
954 : : {
955 : 0 : bPhoneticED1_ChangedByUser = pEdit->GetText().Len()>0;
956 : : }
957 : 0 : else if(&aPhoneticED2 == pEdit)
958 : : {
959 : 0 : bPhoneticED2_ChangedByUser = pEdit->GetText().Len()>0;
960 : : }
961 : 0 : return 0;
962 : : }
963 : :
964 : : /*--------------------------------------------------------------------
965 : : Description: Enable Disable of the 2nd key
966 : : --------------------------------------------------------------------*/
967 : 0 : IMPL_LINK( SwIndexMarkDlg, KeyDCBModifyHdl, ComboBox *, pBox )
968 : : {
969 : 0 : if(&aKeyDCB == pBox)
970 : : {
971 : 0 : sal_Bool bEnable = pBox->GetText().Len() > 0;
972 : 0 : if(!bEnable)
973 : : {
974 : 0 : aKey2DCB.SetText(aEmptyStr);
975 : 0 : aPhoneticED1.SetText(aEmptyStr);
976 : 0 : aPhoneticED2.SetText(aEmptyStr);
977 : 0 : bPhoneticED1_ChangedByUser = sal_False;
978 : 0 : bPhoneticED2_ChangedByUser = sal_False;
979 : : }
980 : : else
981 : : {
982 : 0 : if(pBox->IsInDropDown())
983 : : {
984 : : //reset bPhoneticED1_ChangedByUser if a completly new string is selected
985 : 0 : bPhoneticED1_ChangedByUser = sal_False;
986 : : }
987 : 0 : if(!bPhoneticED1_ChangedByUser)
988 : 0 : aPhoneticED1.SetText(GetDefaultPhoneticReading(pBox->GetText()));
989 : : }
990 : 0 : aKey2DCB.Enable(bEnable);
991 : 0 : aKey2FT.Enable(bEnable);
992 : : }
993 : 0 : else if(&aKey2DCB == pBox)
994 : : {
995 : 0 : if(!(pBox->GetText().Len()>0))
996 : : {
997 : 0 : aPhoneticED2.SetText(aEmptyStr);
998 : 0 : bPhoneticED2_ChangedByUser = sal_False;
999 : : }
1000 : : else
1001 : : {
1002 : 0 : if(pBox->IsInDropDown())
1003 : : {
1004 : : //reset bPhoneticED1_ChangedByUser if a completly new string is selected
1005 : 0 : bPhoneticED2_ChangedByUser = sal_False;
1006 : : }
1007 : 0 : if(!bPhoneticED2_ChangedByUser)
1008 : 0 : aPhoneticED2.SetText(GetDefaultPhoneticReading(pBox->GetText()));
1009 : : }
1010 : : }
1011 : 0 : sal_Bool bKey1HasText = (0 != aKeyDCB.GetText().Len());
1012 : 0 : sal_Bool bKey2HasText = (0 != aKey2DCB.GetText().Len());
1013 : :
1014 : 0 : aPhoneticFT1.Enable(bKey1HasText&&bIsPhoneticReadingEnabled);
1015 : 0 : aPhoneticED1.Enable(bKey1HasText&bIsPhoneticReadingEnabled);
1016 : 0 : aPhoneticFT2.Enable(bKey2HasText&bIsPhoneticReadingEnabled);
1017 : 0 : aPhoneticED2.Enable(bKey2HasText&bIsPhoneticReadingEnabled);
1018 : :
1019 : 0 : return 0;
1020 : : }
1021 : :
1022 : : /*--------------------------------------------------
1023 : : overload dtor
1024 : : --------------------------------------------------*/
1025 : 0 : SwIndexMarkDlg::~SwIndexMarkDlg()
1026 : : {
1027 : 0 : delete pTOXMgr;
1028 : 0 : ViewShell::SetCareWin( 0 );
1029 : 0 : }
1030 : :
1031 : 0 : void SwIndexMarkDlg::ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark* pCurTOXMark)
1032 : : {
1033 : 0 : pSh = &rWrtShell;
1034 : 0 : delete pTOXMgr;
1035 : 0 : pTOXMgr = new SwTOXMgr(pSh);
1036 : 0 : if(pCurTOXMark)
1037 : : {
1038 : 0 : for(sal_uInt16 i = 0; i < pTOXMgr->GetTOXMarkCount(); i++)
1039 : 0 : if(pTOXMgr->GetTOXMark(i) == pCurTOXMark)
1040 : : {
1041 : 0 : pTOXMgr->SetCurTOXMark(i);
1042 : 0 : break;
1043 : : }
1044 : : }
1045 : 0 : InitControls();
1046 : 0 : }
1047 : :
1048 : 0 : SwIndexMarkFloatDlg::SwIndexMarkFloatDlg(SfxBindings* _pBindings,
1049 : : SfxChildWindow* pChild,
1050 : : Window *pParent,
1051 : : SfxChildWinInfo* pInfo,
1052 : : sal_Bool bNew) :
1053 : 0 : SfxModelessDialog(_pBindings, pChild, pParent, SvtCJKOptions().IsCJKFontEnabled()?SW_RES(DLG_INSIDXMARK_CJK):SW_RES(DLG_INSIDXMARK)),
1054 : 0 : aDlg(this, bNew, SW_RES(WIN_DLG), SvtCJKOptions().IsCJKFontEnabled()?DLG_INSIDXMARK_CJK:DLG_INSIDXMARK, *::GetActiveWrtShell())
1055 : : {
1056 : 0 : FreeResource();
1057 : 0 : aDlg.ReInitDlg(*::GetActiveWrtShell());
1058 : 0 : Initialize(pInfo);
1059 : 0 : }
1060 : :
1061 : 0 : void SwIndexMarkFloatDlg::Activate()
1062 : : {
1063 : 0 : SfxModelessDialog::Activate();
1064 : 0 : aDlg.Activate();
1065 : 0 : }
1066 : :
1067 : 0 : void SwIndexMarkFloatDlg::ReInitDlg(SwWrtShell& rWrtShell)
1068 : : {
1069 : 0 : aDlg.ReInitDlg( rWrtShell );
1070 : 0 : }
1071 : :
1072 : 0 : SwIndexMarkModalDlg::SwIndexMarkModalDlg(Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark) :
1073 : 0 : SvxStandardDialog(pParent, SvtCJKOptions().IsCJKFontEnabled()?SW_RES(DLG_EDIT_IDXMARK_CJK):SW_RES(DLG_EDIT_IDXMARK)),
1074 : 0 : aDlg(this, sal_False, SW_RES(WIN_DLG), SvtCJKOptions().IsCJKFontEnabled()?DLG_EDIT_IDXMARK_CJK:DLG_EDIT_IDXMARK, rSh)
1075 : : {
1076 : 0 : FreeResource();
1077 : 0 : aDlg.ReInitDlg(rSh, pCurTOXMark);
1078 : 0 : }
1079 : :
1080 : 0 : void SwIndexMarkModalDlg::Apply()
1081 : : {
1082 : 0 : aDlg.Apply();
1083 : 0 : }
1084 : :
1085 : : class SwCreateAuthEntryDlg_Impl : public ModalDialog
1086 : : {
1087 : : FixedLine aEntriesFL;
1088 : :
1089 : : FixedText* pFixedTexts[AUTH_FIELD_END];
1090 : : ListBox* pTypeListBox;
1091 : : ComboBox* pIdentifierBox;
1092 : : Edit* pEdits[AUTH_FIELD_END];
1093 : :
1094 : : OKButton aOKBT;
1095 : : CancelButton aCancelBT;
1096 : : HelpButton aHelpBT;
1097 : :
1098 : : Link aShortNameCheckLink;
1099 : :
1100 : : SwWrtShell& rWrtSh;
1101 : :
1102 : : sal_Bool m_bNewEntryMode;
1103 : : sal_Bool m_bNameAllowed;
1104 : :
1105 : : DECL_LINK(IdentifierHdl, ComboBox*);
1106 : : DECL_LINK(ShortNameHdl, Edit*);
1107 : : DECL_LINK(EnableHdl, ListBox* pBox);
1108 : :
1109 : : public:
1110 : : SwCreateAuthEntryDlg_Impl(Window* pParent,
1111 : : const String pFields[],
1112 : : SwWrtShell& rSh,
1113 : : sal_Bool bNewEntry,
1114 : : sal_Bool bCreate);
1115 : : ~SwCreateAuthEntryDlg_Impl();
1116 : :
1117 : : String GetEntryText(ToxAuthorityField eField) const;
1118 : :
1119 : 0 : void SetCheckNameHdl(const Link& rLink) {aShortNameCheckLink = rLink;}
1120 : :
1121 : : };
1122 : :
1123 : : struct TextInfo
1124 : : {
1125 : : ToxAuthorityField nToxField;
1126 : : const char* pHelpId;
1127 : : };
1128 : :
1129 : : static const TextInfo aTextInfoArr[] =
1130 : : {
1131 : : {AUTH_FIELD_IDENTIFIER, HID_AUTH_FIELD_IDENTIFIER },
1132 : : {AUTH_FIELD_AUTHORITY_TYPE, HID_AUTH_FIELD_AUTHORITY_TYPE },
1133 : : {AUTH_FIELD_AUTHOR, HID_AUTH_FIELD_AUTHOR },
1134 : : {AUTH_FIELD_TITLE, HID_AUTH_FIELD_TITLE },
1135 : : {AUTH_FIELD_YEAR, HID_AUTH_FIELD_YEAR },
1136 : : {AUTH_FIELD_PUBLISHER, HID_AUTH_FIELD_PUBLISHER },
1137 : : {AUTH_FIELD_ADDRESS, HID_AUTH_FIELD_ADDRESS },
1138 : : {AUTH_FIELD_ISBN, HID_AUTH_FIELD_ISBN },
1139 : : {AUTH_FIELD_CHAPTER, HID_AUTH_FIELD_CHAPTER },
1140 : : {AUTH_FIELD_PAGES, HID_AUTH_FIELD_PAGES },
1141 : : {AUTH_FIELD_EDITOR, HID_AUTH_FIELD_EDITOR },
1142 : : {AUTH_FIELD_EDITION, HID_AUTH_FIELD_EDITION },
1143 : : {AUTH_FIELD_BOOKTITLE, HID_AUTH_FIELD_BOOKTITLE },
1144 : : {AUTH_FIELD_VOLUME, HID_AUTH_FIELD_VOLUME },
1145 : : {AUTH_FIELD_HOWPUBLISHED, HID_AUTH_FIELD_HOWPUBLISHED },
1146 : : {AUTH_FIELD_ORGANIZATIONS, HID_AUTH_FIELD_ORGANIZATIONS },
1147 : : {AUTH_FIELD_INSTITUTION, HID_AUTH_FIELD_INSTITUTION },
1148 : : {AUTH_FIELD_SCHOOL, HID_AUTH_FIELD_SCHOOL },
1149 : : {AUTH_FIELD_REPORT_TYPE, HID_AUTH_FIELD_REPORT_TYPE },
1150 : : {AUTH_FIELD_MONTH, HID_AUTH_FIELD_MONTH },
1151 : : {AUTH_FIELD_JOURNAL, HID_AUTH_FIELD_JOURNAL },
1152 : : {AUTH_FIELD_NUMBER, HID_AUTH_FIELD_NUMBER },
1153 : : {AUTH_FIELD_SERIES, HID_AUTH_FIELD_SERIES },
1154 : : {AUTH_FIELD_ANNOTE, HID_AUTH_FIELD_ANNOTE },
1155 : : {AUTH_FIELD_NOTE, HID_AUTH_FIELD_NOTE },
1156 : : {AUTH_FIELD_URL, HID_AUTH_FIELD_URL },
1157 : : {AUTH_FIELD_CUSTOM1, HID_AUTH_FIELD_CUSTOM1 },
1158 : : {AUTH_FIELD_CUSTOM2, HID_AUTH_FIELD_CUSTOM2 },
1159 : : {AUTH_FIELD_CUSTOM3, HID_AUTH_FIELD_CUSTOM3 },
1160 : : {AUTH_FIELD_CUSTOM4, HID_AUTH_FIELD_CUSTOM4 },
1161 : : {AUTH_FIELD_CUSTOM5, HID_AUTH_FIELD_CUSTOM5 }
1162 : : };
1163 : :
1164 : : sal_Bool SwAuthMarkDlg::bIsFromComponent = sal_True;
1165 : :
1166 : 0 : SwAuthMarkDlg::SwAuthMarkDlg( Window *pParent,
1167 : : const ResId& rResId,
1168 : : sal_Bool bNewDlg) :
1169 : : Window(pParent, rResId),
1170 : 0 : aFromComponentRB( this, ResId(RB_FROMCOMPONENT, *rResId.GetResMgr() )),
1171 : 0 : aFromDocContentRB( this, ResId(RB_FROMDOCCONTENT, *rResId.GetResMgr() )),
1172 : :
1173 : 0 : aAuthorFT( this, ResId(FT_AUTHOR, *rResId.GetResMgr() )),
1174 : 0 : aAuthorFI( this, ResId(FI_AUTHOR, *rResId.GetResMgr() )),
1175 : 0 : aTitleFT( this, ResId(FT_TITLE, *rResId.GetResMgr() )),
1176 : 0 : aTitleFI( this, ResId(FI_TITLE, *rResId.GetResMgr() )),
1177 : 0 : aEntryFT( this, ResId(FT_ENTRY, *rResId.GetResMgr() )),
1178 : 0 : aEntryED( this, ResId(ED_ENTRY, *rResId.GetResMgr() )),
1179 : 0 : aEntryLB( this, ResId(LB_ENTRY, *rResId.GetResMgr() )),
1180 : :
1181 : 0 : aEntryFL( this, ResId(FL_ENTRY, *rResId.GetResMgr() )),
1182 : :
1183 : 0 : aOKBT( this, ResId(PB_OK, *rResId.GetResMgr() )),
1184 : 0 : aCancelBT( this, ResId(PB_CANCEL, *rResId.GetResMgr() )),
1185 : 0 : aHelpBT( this, ResId(PB_HELP, *rResId.GetResMgr() )),
1186 : 0 : aCreateEntryPB(this,ResId(PB_CREATEENTRY, *rResId.GetResMgr())),
1187 : 0 : aEditEntryPB(this, ResId(PB_EDITENTRY, *rResId.GetResMgr())),
1188 : :
1189 : 0 : sChangeST( ResId(ST_CHANGE, *rResId.GetResMgr())),
1190 : : bNewEntry(bNewDlg),
1191 : : bBibAccessInitialized(sal_False),
1192 : :
1193 : 0 : pSh(0)
1194 : : {
1195 : 0 : SetStyle(GetStyle()|WB_DIALOGCONTROL);
1196 : 0 : FreeResource();
1197 : :
1198 : 0 : aFromComponentRB.SetHelpId(HID_AUTH_MARK_DLG_FROM_COMP_RB);
1199 : 0 : aFromDocContentRB.SetHelpId(HID_AUTH_MARK_DLG_FROM_DOC_RB );
1200 : 0 : aEntryED.SetHelpId(HID_AUTH_MARK_DLG_ID_LISTBOX );
1201 : 0 : aEntryLB.SetHelpId(HID_AUTH_MARK_DLG_ID_LISTBOX );
1202 : :
1203 : 0 : aFromComponentRB.Show(bNewEntry);
1204 : 0 : aFromDocContentRB.Show(bNewEntry);
1205 : 0 : aFromComponentRB.Check(bIsFromComponent);
1206 : 0 : aFromDocContentRB.Check(!bIsFromComponent);
1207 : :
1208 : 0 : aOKBT .SetHelpId(HID_INSERT_AUTH_MRK_OK );
1209 : 0 : aCancelBT .SetHelpId(HID_INSERT_AUTH_MRK_CLOSE);
1210 : 0 : aEntryED .SetHelpId(HID_INSERT_AUTH_MRK_ENTRY );
1211 : 0 : aCreateEntryPB .SetHelpId(HID_INSERT_AUTH_MRK_CREATE_ENTRY );
1212 : 0 : aEditEntryPB .SetHelpId(HID_INSERT_AUTH_MRK_EDIT_ENTRY );
1213 : :
1214 : 0 : aOKBT.SetClickHdl(LINK(this,SwAuthMarkDlg, InsertHdl));
1215 : 0 : aCancelBT.SetClickHdl(LINK(this,SwAuthMarkDlg, CloseHdl));
1216 : 0 : aCreateEntryPB.SetClickHdl(LINK(this,SwAuthMarkDlg, CreateEntryHdl));
1217 : 0 : aEditEntryPB.SetClickHdl(LINK(this,SwAuthMarkDlg, CreateEntryHdl));
1218 : 0 : aFromComponentRB.SetClickHdl(LINK(this,SwAuthMarkDlg, ChangeSourceHdl));
1219 : 0 : aFromDocContentRB.SetClickHdl(LINK(this,SwAuthMarkDlg, ChangeSourceHdl));
1220 : 0 : aEntryED.SetModifyHdl(LINK(this,SwAuthMarkDlg, EditModifyHdl));
1221 : :
1222 : 0 : GetParent()->SetText(String(SW_RES(
1223 : 0 : bNewEntry ? STR_AUTHMRK_INSERT : STR_AUTHMRK_EDIT)));
1224 : 0 : aEntryED.Show(!bNewEntry);
1225 : 0 : aEntryLB.Show(bNewEntry);
1226 : 0 : if(!bNewEntry)
1227 : : {
1228 : 0 : aOKBT.SetText(sChangeST);
1229 : : }
1230 : : else
1231 : : {
1232 : 0 : aEntryLB.SetSelectHdl(LINK(this, SwAuthMarkDlg, CompEntryHdl));
1233 : : }
1234 : 0 : }
1235 : :
1236 : 0 : SwAuthMarkDlg::~SwAuthMarkDlg()
1237 : : {
1238 : 0 : }
1239 : :
1240 : 0 : void SwAuthMarkDlg::ReInitDlg(SwWrtShell& rWrtShell)
1241 : : {
1242 : 0 : pSh = &rWrtShell;
1243 : 0 : InitControls();
1244 : 0 : }
1245 : :
1246 : 0 : IMPL_LINK_NOARG(SwAuthMarkDlg, CloseHdl)
1247 : : {
1248 : 0 : if(bNewEntry)
1249 : : {
1250 : 0 : sal_uInt16 nSlot = FN_INSERT_AUTH_ENTRY_DLG;
1251 : : SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot,
1252 : 0 : SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD);
1253 : : }
1254 : : else
1255 : : {
1256 : 0 : ((SwAuthMarkModalDlg*)GetParent())->EndDialog(RET_CANCEL);
1257 : : }
1258 : 0 : return 0;
1259 : : }
1260 : :
1261 : 0 : static String lcl_FindColumnEntry(const beans::PropertyValue* pFields, sal_Int32 nLen, const String& rColumnTitle)
1262 : : {
1263 : 0 : String sRet;
1264 : 0 : OUString uColumnTitle = rColumnTitle;
1265 : 0 : for(sal_uInt16 i = 0; i < nLen; i++)
1266 : : {
1267 : 0 : OUString uTmp;
1268 : 0 : if(pFields[i].Name == uColumnTitle &&
1269 : 0 : (pFields[i].Value >>= uTmp))
1270 : : {
1271 : 0 : sRet = String(uTmp);
1272 : : break;
1273 : : }
1274 : 0 : }
1275 : 0 : return sRet;
1276 : : }
1277 : :
1278 : 0 : IMPL_LINK( SwAuthMarkDlg, CompEntryHdl, ListBox*, pBox)
1279 : : {
1280 : 0 : String sEntry(pBox->GetSelectEntry());
1281 : 0 : if(bIsFromComponent)
1282 : : {
1283 : 0 : if(xBibAccess.is() && sEntry.Len())
1284 : : {
1285 : 0 : OUString uEntry(sEntry);
1286 : 0 : if(xBibAccess->hasByName(uEntry))
1287 : : {
1288 : 0 : uno::Any aEntry(xBibAccess->getByName(uEntry));
1289 : 0 : uno::Sequence<beans::PropertyValue> aFieldProps;
1290 : 0 : if(aEntry >>= aFieldProps)
1291 : : {
1292 : 0 : const beans::PropertyValue* pProps = aFieldProps.getConstArray();
1293 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END && i < aFieldProps.getLength(); i++)
1294 : : {
1295 : 0 : m_sFields[i] = lcl_FindColumnEntry(
1296 : 0 : pProps, aFieldProps.getLength(), m_sColumnTitles[i]);
1297 : : }
1298 : 0 : }
1299 : 0 : }
1300 : : }
1301 : : }
1302 : : else
1303 : : {
1304 : 0 : if(sEntry.Len())
1305 : : {
1306 : : const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
1307 : 0 : pSh->GetFldType(RES_AUTHORITY, aEmptyStr);
1308 : 0 : const SwAuthEntry* pEntry = pFType ? pFType->GetEntryByIdentifier(sEntry) : 0;
1309 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1310 : 0 : m_sFields[i] = pEntry ?
1311 : 0 : pEntry->GetAuthorField((ToxAuthorityField)i) : aEmptyStr;
1312 : : }
1313 : : }
1314 : 0 : if(!pBox->GetSelectEntry().Len())
1315 : : {
1316 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1317 : 0 : m_sFields[i] = aEmptyStr;
1318 : : }
1319 : 0 : aAuthorFI.SetText(m_sFields[AUTH_FIELD_AUTHOR]);
1320 : 0 : aTitleFI.SetText(m_sFields[AUTH_FIELD_TITLE]);
1321 : 0 : return 0;
1322 : : }
1323 : :
1324 : 0 : IMPL_LINK_NOARG(SwAuthMarkDlg, InsertHdl)
1325 : : {
1326 : : //insert or update the SwAuthorityField...
1327 : 0 : if(pSh)
1328 : : {
1329 : 0 : sal_Bool bDifferent = sal_False;
1330 : : OSL_ENSURE(m_sFields[AUTH_FIELD_IDENTIFIER].Len() , "No Id is set!");
1331 : : OSL_ENSURE(m_sFields[AUTH_FIELD_AUTHORITY_TYPE].Len() , "No authority type is set!");
1332 : : //check if the entry already exists with different content
1333 : : const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
1334 : 0 : pSh->GetFldType(RES_AUTHORITY, aEmptyStr);
1335 : : const SwAuthEntry* pEntry = pFType ?
1336 : 0 : pFType->GetEntryByIdentifier( m_sFields[AUTH_FIELD_IDENTIFIER])
1337 : 0 : : 0;
1338 : 0 : if(pEntry)
1339 : : {
1340 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END && !bDifferent; i++)
1341 : 0 : bDifferent |= m_sFields[i] != pEntry->GetAuthorField((ToxAuthorityField)i);
1342 : 0 : if(bDifferent)
1343 : : {
1344 : 0 : QueryBox aQuery(this, SW_RES(DLG_CHANGE_AUTH_ENTRY));
1345 : 0 : if(RET_YES != aQuery.Execute())
1346 : 0 : return 0;
1347 : : }
1348 : : }
1349 : :
1350 : 0 : SwFldMgr aMgr(pSh);
1351 : 0 : String sFields;
1352 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1353 : : {
1354 : 0 : sFields += m_sFields[i];
1355 : 0 : sFields += TOX_STYLE_DELIMITER;
1356 : : }
1357 : 0 : if(bNewEntry)
1358 : : {
1359 : 0 : if(bDifferent)
1360 : : {
1361 : 0 : SwAuthEntry aNewData;
1362 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1363 : 0 : aNewData.SetAuthorField((ToxAuthorityField)i, m_sFields[i]);
1364 : 0 : pSh->ChangeAuthorityData(&aNewData);
1365 : : }
1366 : 0 : SwInsertFld_Data aData(TYP_AUTHORITY, 0, sFields, aEmptyStr, 0 );
1367 : 0 : aMgr.InsertFld( aData );
1368 : : }
1369 : 0 : else if(aMgr.GetCurFld())
1370 : : {
1371 : 0 : aMgr.UpdateCurFld(0, sFields, aEmptyStr);
1372 : 0 : }
1373 : : }
1374 : 0 : if(!bNewEntry)
1375 : 0 : CloseHdl(0);
1376 : 0 : return 0;
1377 : : }
1378 : :
1379 : 0 : IMPL_LINK(SwAuthMarkDlg, CreateEntryHdl, PushButton*, pButton)
1380 : : {
1381 : 0 : sal_Bool bCreate = pButton == &aCreateEntryPB;
1382 : 0 : String sOldId = m_sCreatedEntry[0];
1383 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1384 : 0 : m_sCreatedEntry[i] = bCreate ? aEmptyStr : m_sFields[i];
1385 : : SwCreateAuthEntryDlg_Impl aDlg(pButton,
1386 : : bCreate ? m_sCreatedEntry : m_sFields,
1387 : 0 : *pSh, bNewEntry, bCreate);
1388 : 0 : if(bNewEntry)
1389 : : {
1390 : 0 : aDlg.SetCheckNameHdl(LINK(this, SwAuthMarkDlg, IsEntryAllowedHdl));
1391 : : }
1392 : 0 : if(RET_OK == aDlg.Execute())
1393 : : {
1394 : 0 : if(bCreate && sOldId.Len())
1395 : : {
1396 : 0 : aEntryLB.RemoveEntry(sOldId);
1397 : : }
1398 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1399 : : {
1400 : 0 : m_sFields[i] = aDlg.GetEntryText((ToxAuthorityField)i);
1401 : 0 : m_sCreatedEntry[i] = m_sFields[i];
1402 : : }
1403 : 0 : if(bNewEntry && !aFromDocContentRB.IsChecked())
1404 : : {
1405 : 0 : aFromDocContentRB.Check(sal_True);
1406 : 0 : ChangeSourceHdl(&aFromDocContentRB);
1407 : : }
1408 : 0 : if(bCreate)
1409 : : {
1410 : : OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND ==
1411 : : aEntryLB.GetEntryPos(m_sFields[AUTH_FIELD_IDENTIFIER]),
1412 : : "entry exists!");
1413 : 0 : aEntryLB.InsertEntry(m_sFields[AUTH_FIELD_IDENTIFIER]);
1414 : 0 : aEntryLB.SelectEntry(m_sFields[AUTH_FIELD_IDENTIFIER]);
1415 : : }
1416 : 0 : aEntryED.SetText(m_sFields[AUTH_FIELD_IDENTIFIER]);
1417 : 0 : aAuthorFI.SetText(m_sFields[AUTH_FIELD_AUTHOR]);
1418 : 0 : aTitleFI.SetText(m_sFields[AUTH_FIELD_TITLE]);
1419 : 0 : aOKBT.Enable();
1420 : : }
1421 : 0 : return 0;
1422 : : }
1423 : :
1424 : 0 : IMPL_LINK(SwAuthMarkDlg, ChangeSourceHdl, RadioButton*, pButton)
1425 : : {
1426 : 0 : sal_Bool bFromComp = (pButton == &aFromComponentRB);
1427 : 0 : bIsFromComponent = bFromComp;
1428 : 0 : aCreateEntryPB.Enable(!bIsFromComponent);
1429 : 0 : aEntryLB.Clear();
1430 : 0 : if(bIsFromComponent)
1431 : : {
1432 : 0 : if(!bBibAccessInitialized)
1433 : : {
1434 : 0 : uno::Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
1435 : : xBibAccess = uno::Reference< container::XNameAccess > (
1436 : 0 : xMSF->createInstance( C2U("com.sun.star.frame.Bibliography") ),
1437 : 0 : uno::UNO_QUERY );
1438 : 0 : uno::Reference< beans::XPropertySet > xPropSet(xBibAccess, uno::UNO_QUERY);
1439 : 0 : OUString uPropName(C2U("BibliographyDataFieldNames"));
1440 : 0 : if(xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName(uPropName))
1441 : : {
1442 : 0 : uno::Any aNames = xPropSet->getPropertyValue(uPropName);
1443 : 0 : uno::Sequence<beans::PropertyValue> aSeq;
1444 : 0 : if( aNames >>= aSeq)
1445 : : {
1446 : 0 : const beans::PropertyValue* pArr = aSeq.getConstArray();
1447 : 0 : for(sal_uInt16 i = 0; i < aSeq.getLength(); i++)
1448 : : {
1449 : 0 : String sTitle = pArr[i].Name;
1450 : 0 : sal_Int16 nField = 0;
1451 : 0 : pArr[i].Value >>= nField;
1452 : 0 : if(nField >= 0 && nField < AUTH_FIELD_END)
1453 : 0 : m_sColumnTitles[nField] = sTitle;
1454 : 0 : }
1455 : 0 : }
1456 : : }
1457 : 0 : bBibAccessInitialized = sal_True;
1458 : : }
1459 : 0 : if(xBibAccess.is())
1460 : : {
1461 : 0 : uno::Sequence<OUString> aIdentifiers = xBibAccess->getElementNames();
1462 : 0 : const OUString* pNames = aIdentifiers.getConstArray();
1463 : 0 : for(sal_uInt16 i = 0; i < aIdentifiers.getLength(); i++)
1464 : : {
1465 : 0 : aEntryLB.InsertEntry(pNames[i]);
1466 : 0 : }
1467 : : }
1468 : : }
1469 : : else
1470 : : {
1471 : : const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
1472 : 0 : pSh->GetFldType(RES_AUTHORITY, aEmptyStr);
1473 : 0 : if(pFType)
1474 : : {
1475 : 0 : std::vector<String> aIds;
1476 : 0 : pFType->GetAllEntryIdentifiers( aIds );
1477 : 0 : for(size_t n = 0; n < aIds.size(); ++n)
1478 : 0 : aEntryLB.InsertEntry(aIds[n]);
1479 : : }
1480 : 0 : if(m_sCreatedEntry[AUTH_FIELD_IDENTIFIER].Len())
1481 : 0 : aEntryLB.InsertEntry(m_sCreatedEntry[AUTH_FIELD_IDENTIFIER]);
1482 : : }
1483 : 0 : aEntryLB.SelectEntryPos(0);
1484 : 0 : CompEntryHdl(&aEntryLB);
1485 : 0 : return 0;
1486 : : }
1487 : :
1488 : 0 : IMPL_LINK(SwAuthMarkDlg, EditModifyHdl, Edit*, pEdit)
1489 : : {
1490 : 0 : Link aAllowed = LINK(this, SwAuthMarkDlg, IsEntryAllowedHdl);
1491 : 0 : long nResult = aAllowed.Call(pEdit);
1492 : 0 : aOKBT.Enable(nResult > 0);
1493 : 0 : if(nResult)
1494 : : {
1495 : 0 : String sEntry(pEdit->GetText());
1496 : 0 : m_sFields[AUTH_FIELD_IDENTIFIER] = sEntry;
1497 : 0 : m_sCreatedEntry[AUTH_FIELD_IDENTIFIER] = sEntry;
1498 : : }
1499 : 0 : return 0;
1500 : : };
1501 : :
1502 : 0 : IMPL_LINK(SwAuthMarkDlg, IsEntryAllowedHdl, Edit*, pEdit)
1503 : : {
1504 : 0 : String sEntry = pEdit->GetText();
1505 : 0 : sal_Bool bAllowed = sal_False;
1506 : 0 : if(sEntry.Len())
1507 : : {
1508 : 0 : if(aEntryLB.GetEntryPos(sEntry) != LISTBOX_ENTRY_NOTFOUND)
1509 : 0 : return 0;
1510 : 0 : else if(bIsFromComponent)
1511 : : {
1512 : : const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
1513 : 0 : pSh->GetFldType(RES_AUTHORITY, aEmptyStr);
1514 : 0 : bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
1515 : : }
1516 : : else
1517 : : {
1518 : 0 : bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
1519 : : }
1520 : : }
1521 : 0 : return bAllowed;
1522 : : }
1523 : :
1524 : 0 : void SwAuthMarkDlg::InitControls()
1525 : : {
1526 : : OSL_ENSURE(pSh, "no shell?");
1527 : 0 : SwField* pField = pSh->GetCurFld();
1528 : : OSL_ENSURE(bNewEntry || pField, "no current marker");
1529 : 0 : if(bNewEntry)
1530 : : {
1531 : 0 : ChangeSourceHdl(aFromComponentRB.IsChecked() ? &aFromComponentRB : &aFromDocContentRB);
1532 : 0 : aCreateEntryPB.Enable(!aFromComponentRB.IsChecked());
1533 : 0 : if(!aFromComponentRB.IsChecked() && m_sCreatedEntry[0].Len())
1534 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1535 : 0 : m_sFields[i] = m_sCreatedEntry[i];
1536 : : }
1537 : 0 : if(bNewEntry || !pField || pField->GetTyp()->Which() != RES_AUTHORITY)
1538 : 0 : return;
1539 : :
1540 : 0 : const SwAuthEntry* pEntry = ((SwAuthorityFieldType*)pField->GetTyp())->
1541 : 0 : GetEntryByHandle(((SwAuthorityField*)pField)->GetHandle());
1542 : :
1543 : : OSL_ENSURE(pEntry, "No authority entry found");
1544 : 0 : if(!pEntry)
1545 : 0 : return;
1546 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1547 : 0 : m_sFields[i] = pEntry->GetAuthorField((ToxAuthorityField)i);
1548 : :
1549 : 0 : aEntryED.SetText(pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER));
1550 : 0 : aAuthorFI.SetText(pEntry->GetAuthorField(AUTH_FIELD_AUTHOR));
1551 : 0 : aTitleFI.SetText(pEntry->GetAuthorField(AUTH_FIELD_TITLE));
1552 : : }
1553 : :
1554 : 0 : void SwAuthMarkDlg::Activate()
1555 : : {
1556 : 0 : aOKBT.Enable(!pSh->HasReadonlySel());
1557 : 0 : Window::Activate();
1558 : 0 : }
1559 : :
1560 : 0 : SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(Window* pParent,
1561 : : const String pFields[],
1562 : : SwWrtShell& rSh,
1563 : : sal_Bool bNewEntry,
1564 : : sal_Bool bCreate) :
1565 : : ModalDialog(pParent, SW_RES(DLG_CREATE_AUTH_ENTRY)),
1566 : : aEntriesFL(this, SW_RES(FL_ENTRIES )),
1567 : : pTypeListBox(0),
1568 : : pIdentifierBox(0),
1569 : : aOKBT(this, SW_RES(PB_OK )),
1570 : : aCancelBT(this, SW_RES(PB_CANCEL )),
1571 : : aHelpBT(this, SW_RES(PB_HELP )),
1572 : : rWrtSh(rSh),
1573 : : m_bNewEntryMode(bNewEntry),
1574 : 0 : m_bNameAllowed(sal_True)
1575 : : {
1576 : 0 : FreeResource();
1577 : 0 : Point aFLPos(aEntriesFL.GetPosPixel());
1578 : 0 : Point aTL1(aFLPos);
1579 : 0 : Size aFLSz(aEntriesFL.GetSizePixel().Width(), GetSizePixel().Height());
1580 : 0 : long nControlSpace = aFLSz.Width() / 4;
1581 : 0 : long nControlWidth = nControlSpace - 2 * aTL1.X();
1582 : 0 : aTL1.X() *= 2;
1583 : 0 : aTL1.Y() *= 5;
1584 : 0 : Point aTR1(aTL1);
1585 : 0 : aTR1.X() += nControlSpace;
1586 : 0 : Point aTL2(aTR1);
1587 : 0 : aTL2.X() += nControlSpace;
1588 : 0 : Point aTR2(aTL2);
1589 : 0 : aTR2.X() += nControlSpace;
1590 : 0 : Size aFixedTextSize(aFLSz);
1591 : 0 : Size aTmpSz(8,10);
1592 : 0 : aTmpSz = LogicToPixel(aTmpSz, MAP_APPFONT);
1593 : 0 : aFixedTextSize.Height() = aTmpSz.Width();
1594 : 0 : Size aEditSize(aFixedTextSize);
1595 : 0 : aFixedTextSize.Width() = nControlWidth + aFLPos.X();
1596 : 0 : aEditSize.Height() = aTmpSz.Height();
1597 : 0 : aEditSize.Width() = nControlWidth;
1598 : :
1599 : 0 : sal_uInt16 nOffset = static_cast< sal_uInt16 >(aTmpSz.Width() * 3 / 2);
1600 : 0 : sal_Bool bLeft = sal_True;
1601 : 0 : Window* pRefWindow = 0;
1602 : 0 : for(sal_uInt16 nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1603 : : {
1604 : 0 : const TextInfo aCurInfo = aTextInfoArr[nIndex];
1605 : :
1606 : 0 : pFixedTexts[nIndex] = new FixedText(this);
1607 : 0 : if(nIndex)
1608 : 0 : pFixedTexts[nIndex]->SetZOrder( pRefWindow, WINDOW_ZORDER_BEHIND );
1609 : : else
1610 : 0 : pFixedTexts[nIndex]->SetZOrder( 0, WINDOW_ZORDER_FIRST );
1611 : :
1612 : 0 : pRefWindow = pFixedTexts[nIndex];
1613 : :
1614 : 0 : pFixedTexts[nIndex]->SetSizePixel(aFixedTextSize);
1615 : 0 : pFixedTexts[nIndex]->SetPosPixel(bLeft ? aTL1 : aTL2);
1616 : 0 : pFixedTexts[nIndex]->SetText(SW_RES(STR_AUTH_FIELD_START + aCurInfo.nToxField));
1617 : 0 : pFixedTexts[nIndex]->Show();
1618 : 0 : pEdits[nIndex] = 0;
1619 : 0 : if( AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField )
1620 : : {
1621 : 0 : pTypeListBox = new ListBox(this, WB_DROPDOWN|WB_BORDER);
1622 : 0 : pTypeListBox->SetZOrder( pRefWindow, WINDOW_ZORDER_BEHIND );
1623 : 0 : pRefWindow = pTypeListBox;
1624 : 0 : for(sal_uInt16 j = 0; j < AUTH_TYPE_END; j++)
1625 : 0 : pTypeListBox->InsertEntry(String(SW_RES(STR_AUTH_TYPE_START + j)));
1626 : 0 : if(pFields[aCurInfo.nToxField].Len())
1627 : : {
1628 : 0 : sal_uInt16 nIndexPos = static_cast< sal_uInt16 >(pFields[aCurInfo.nToxField].ToInt32());
1629 : 0 : pTypeListBox->SelectEntryPos(nIndexPos);
1630 : : }
1631 : 0 : Size aTmp(aEditSize);
1632 : 0 : aTmp.Height() *= 4;
1633 : 0 : pTypeListBox->SetSizePixel(aTmp);
1634 : 0 : pTypeListBox->SetPosPixel(bLeft ? aTR1 : aTR2);
1635 : 0 : pTypeListBox->Show();
1636 : 0 : pTypeListBox->SetSelectHdl(LINK(this, SwCreateAuthEntryDlg_Impl, EnableHdl));
1637 : 0 : pTypeListBox->SetHelpId(aCurInfo.pHelpId);
1638 : :
1639 : : }
1640 : 0 : else if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField && !m_bNewEntryMode)
1641 : : {
1642 : 0 : pIdentifierBox = new ComboBox(this, WB_BORDER|WB_DROPDOWN);
1643 : 0 : pIdentifierBox->SetZOrder( pRefWindow, WINDOW_ZORDER_BEHIND );
1644 : 0 : pRefWindow = pIdentifierBox;
1645 : :
1646 : : pIdentifierBox->SetSelectHdl(LINK(this,
1647 : 0 : SwCreateAuthEntryDlg_Impl, IdentifierHdl));
1648 : :
1649 : :
1650 : : const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
1651 : 0 : rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
1652 : 0 : if(pFType)
1653 : : {
1654 : 0 : std::vector<String> aIds;
1655 : 0 : pFType->GetAllEntryIdentifiers( aIds );
1656 : 0 : for(size_t n = 0; n < aIds.size(); ++n)
1657 : 0 : pIdentifierBox->InsertEntry(aIds[n]);
1658 : : }
1659 : 0 : pIdentifierBox->SetText(pFields[aCurInfo.nToxField]);
1660 : 0 : Size aTmp(aEditSize);
1661 : 0 : aTmp.Height() *= 4;
1662 : 0 : pIdentifierBox->SetSizePixel(aTmp);
1663 : 0 : pIdentifierBox->SetPosPixel(bLeft ? aTR1 : aTR2);
1664 : 0 : pIdentifierBox->Show();
1665 : 0 : pIdentifierBox->SetHelpId(aCurInfo.pHelpId);
1666 : : }
1667 : : else
1668 : : {
1669 : 0 : pEdits[nIndex] = new Edit(this, WB_BORDER);
1670 : 0 : pEdits[nIndex]->SetZOrder( pRefWindow, WINDOW_ZORDER_BEHIND );
1671 : 0 : pRefWindow = pEdits[nIndex];
1672 : 0 : pEdits[nIndex]->SetSizePixel(aEditSize);
1673 : 0 : pEdits[nIndex]->SetPosPixel(bLeft ? aTR1 : aTR2);
1674 : 0 : pEdits[nIndex]->SetText(pFields[aCurInfo.nToxField]);
1675 : 0 : pEdits[nIndex]->Show();
1676 : 0 : pEdits[nIndex]->SetHelpId(aCurInfo.pHelpId);
1677 : 0 : if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1678 : : {
1679 : 0 : pEdits[nIndex]->SetModifyHdl(LINK(this, SwCreateAuthEntryDlg_Impl, ShortNameHdl));
1680 : 0 : m_bNameAllowed = pFields[nIndex].Len() > 0;
1681 : 0 : if(!bCreate)
1682 : : {
1683 : 0 : pFixedTexts[nIndex]->Enable(sal_False);
1684 : 0 : pEdits[nIndex]->Enable(sal_False);
1685 : : }
1686 : : }
1687 : : }
1688 : 0 : if(bLeft)
1689 : : {
1690 : 0 : aTL1.Y() += nOffset;
1691 : 0 : aTR1.Y() += nOffset;
1692 : : }
1693 : : else
1694 : : {
1695 : 0 : aTL2.Y() += nOffset;
1696 : 0 : aTR2.Y() += nOffset;
1697 : : }
1698 : 0 : bLeft = !bLeft;
1699 : : }
1700 : 0 : EnableHdl(pTypeListBox);
1701 : :
1702 : 0 : long nHeightDiff = - aFLSz.Height();
1703 : 0 : aFLSz.Height() = aTL1.Y();
1704 : 0 : nHeightDiff += aFLSz.Height();
1705 : 0 : Size aDlgSize(GetSizePixel());
1706 : 0 : aDlgSize.Height() += nHeightDiff;
1707 : 0 : SetSizePixel(aDlgSize);
1708 : :
1709 : 0 : }
1710 : :
1711 : 0 : SwCreateAuthEntryDlg_Impl::~SwCreateAuthEntryDlg_Impl()
1712 : : {
1713 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1714 : : {
1715 : 0 : delete pFixedTexts[i];
1716 : 0 : delete pEdits[i];
1717 : : }
1718 : 0 : delete pTypeListBox;
1719 : 0 : delete pIdentifierBox;
1720 : 0 : }
1721 : :
1722 : 0 : String SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) const
1723 : : {
1724 : 0 : String sRet;
1725 : 0 : if( AUTH_FIELD_AUTHORITY_TYPE == eField )
1726 : : {
1727 : : OSL_ENSURE(pTypeListBox, "No ListBox");
1728 : 0 : sRet = String::CreateFromInt32(pTypeListBox->GetSelectEntryPos());
1729 : : }
1730 : 0 : else if( AUTH_FIELD_IDENTIFIER == eField && !m_bNewEntryMode)
1731 : : {
1732 : : OSL_ENSURE(pIdentifierBox, "No ComboBox");
1733 : 0 : sRet = pIdentifierBox->GetText();
1734 : : }
1735 : : else
1736 : : {
1737 : 0 : for(sal_uInt16 nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
1738 : : {
1739 : 0 : const TextInfo aCurInfo = aTextInfoArr[nIndex];
1740 : 0 : if(aCurInfo.nToxField == eField)
1741 : : {
1742 : 0 : sRet = pEdits[nIndex]->GetText();
1743 : : break;
1744 : : }
1745 : : }
1746 : : }
1747 : 0 : return sRet;
1748 : : }
1749 : :
1750 : 0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, IdentifierHdl, ComboBox*, pBox)
1751 : : {
1752 : : const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
1753 : 0 : rWrtSh.GetFldType(RES_AUTHORITY, aEmptyStr);
1754 : 0 : if(pFType)
1755 : : {
1756 : : const SwAuthEntry* pEntry = pFType->GetEntryByIdentifier(
1757 : 0 : pBox->GetText());
1758 : 0 : if(pEntry)
1759 : : {
1760 : 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
1761 : : {
1762 : 0 : const TextInfo aCurInfo = aTextInfoArr[i];
1763 : 0 : if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
1764 : 0 : continue;
1765 : 0 : if(AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField)
1766 : : pTypeListBox->SelectEntry(
1767 : 0 : pEntry->GetAuthorField(aCurInfo.nToxField));
1768 : : else
1769 : 0 : pEdits[i]->SetText(
1770 : 0 : pEntry->GetAuthorField(aCurInfo.nToxField));
1771 : : }
1772 : : }
1773 : : }
1774 : 0 : return 0;
1775 : : }
1776 : :
1777 : 0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, ShortNameHdl, Edit*, pEdit)
1778 : : {
1779 : 0 : if(aShortNameCheckLink.IsSet())
1780 : : {
1781 : 0 : sal_Bool bEnable = 0 != aShortNameCheckLink.Call(pEdit);
1782 : 0 : m_bNameAllowed |= bEnable;
1783 : 0 : aOKBT.Enable(pTypeListBox->GetSelectEntryCount() && bEnable);
1784 : : }
1785 : 0 : return 0;
1786 : : }
1787 : :
1788 : 0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, ListBox*, pBox)
1789 : : {
1790 : 0 : aOKBT.Enable(m_bNameAllowed && pBox->GetSelectEntryCount());
1791 : 0 : return 0;
1792 : : };
1793 : :
1794 : 0 : SwAuthMarkFloatDlg::SwAuthMarkFloatDlg(SfxBindings* _pBindings,
1795 : : SfxChildWindow* pChild,
1796 : : Window *pParent,
1797 : : SfxChildWinInfo* pInfo,
1798 : : sal_Bool bNew) :
1799 : : SfxModelessDialog(_pBindings, pChild, pParent, SW_RES(DLG_INSAUTHMARK)),
1800 : 0 : aDlg(this, SW_RES(WIN_DLG), bNew)
1801 : : {
1802 : 0 : FreeResource();
1803 : 0 : Initialize(pInfo);
1804 : 0 : SwWrtShell* pWrtShell = ::GetActiveWrtShell();
1805 : : OSL_ENSURE(pWrtShell, "No shell?");
1806 : 0 : aDlg.ReInitDlg(*pWrtShell);
1807 : 0 : }
1808 : :
1809 : 0 : void SwAuthMarkFloatDlg::Activate()
1810 : : {
1811 : 0 : SfxModelessDialog::Activate();
1812 : 0 : aDlg.Activate();
1813 : 0 : }
1814 : :
1815 : 0 : void SwAuthMarkFloatDlg::ReInitDlg(SwWrtShell& rWrtShell)
1816 : : {
1817 : 0 : aDlg.ReInitDlg( rWrtShell );
1818 : 0 : }
1819 : :
1820 : 0 : SwAuthMarkModalDlg::SwAuthMarkModalDlg(Window *pParent, SwWrtShell& rSh) :
1821 : : SvxStandardDialog(pParent, SW_RES(DLG_EDIT_AUTHMARK)),
1822 : 0 : aDlg(this, SW_RES(WIN_DLG), sal_False)
1823 : : {
1824 : 0 : FreeResource();
1825 : 0 : aDlg.ReInitDlg(rSh);
1826 : 0 : }
1827 : :
1828 : 0 : void SwAuthMarkModalDlg::Apply()
1829 : : {
1830 : 0 : aDlg.InsertHdl(0);
1831 : 0 : }
1832 : :
1833 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|