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 <hintids.hxx>
30 : :
31 : : #include <com/sun/star/lang/Locale.hpp>
32 : : #include <com/sun/star/linguistic2/XThesaurus.hpp>
33 : : #include <com/sun/star/linguistic2/ProofreadingResult.hpp>
34 : : #include <com/sun/star/i18n/TextConversionOption.hpp>
35 : : #include <linguistic/lngprops.hxx>
36 : : #include <comphelper/processfactory.hxx>
37 : : #include <toolkit/helper/vclunohelper.hxx>
38 : : #include <vcl/msgbox.hxx>
39 : : #include <svtools/ehdl.hxx>
40 : : #include <svl/stritem.hxx>
41 : : #include <sfx2/viewfrm.hxx>
42 : : #include <sfx2/request.hxx>
43 : : #include <svx/dlgutil.hxx>
44 : : #include <svx/dialmgr.hxx>
45 : : #include <editeng/langitem.hxx>
46 : : #include <svx/svxerr.hxx>
47 : : #include <editeng/unolingu.hxx>
48 : : #include <svx/svxdlg.hxx>
49 : : #include <editeng/SpellPortions.hxx>
50 : : #include <swmodule.hxx>
51 : : #include <swwait.hxx>
52 : : #include <initui.hxx> // fuer SpellPointer
53 : : #include <uitool.hxx>
54 : : #include <view.hxx>
55 : : #include <wrtsh.hxx>
56 : : #include <basesh.hxx>
57 : : #include <docsh.hxx> // CheckSpellChanges
58 : : #include <viewopt.hxx> // Viewoptions
59 : : #include <swundo.hxx> // fuer Undo-Ids
60 : : #include <hyp.hxx> // Trennung
61 : : #include <olmenu.hxx> // PopupMenu fuer OnlineSpelling
62 : : #include <pam.hxx> // Spelling: Multiselektion
63 : : #include <edtwin.hxx>
64 : : #include <crsskip.hxx>
65 : : #include <ndtxt.hxx>
66 : : #include <vcl/lstbox.hxx>
67 : : #include <cmdid.h>
68 : : #include <globals.hrc>
69 : : #include <comcore.hrc> // STR_MULT_INTERACT_SPELL_WARN
70 : : #include <view.hrc>
71 : : #include <hhcwrp.hxx>
72 : : #include <com/sun/star/frame/XStorable.hpp>
73 : :
74 : : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
75 : : #include <com/sun/star/lang/XInitialization.hpp>
76 : : #include <com/sun/star/frame/XDispatch.hpp>
77 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
78 : : #include <com/sun/star/frame/XFrame.hpp>
79 : : #include <com/sun/star/util/URL.hpp>
80 : : #include <com/sun/star/beans/PropertyValue.hpp>
81 : : #include <com/sun/star/util/URLTransformer.hpp>
82 : : #include <com/sun/star/util/XURLTransformer.hpp>
83 : :
84 : : #include <vcl/svapp.hxx>
85 : : #include <rtl/ustring.hxx>
86 : :
87 : : #include <cppuhelper/bootstrap.hxx>
88 : : #include "stmenu.hxx" // PopupMenu for smarttags
89 : : #include <svx/dialogs.hrc>
90 : : #include <svtools/langtab.hxx>
91 : : #include <unomid.h>
92 : : #include <IMark.hxx>
93 : : #include <xmloff/odffields.hxx>
94 : :
95 : : #include <memory>
96 : : #include <editeng/editerr.hxx>
97 : :
98 : : using namespace sw::mark;
99 : : using ::rtl::OUString;
100 : : using namespace ::com::sun::star;
101 : : using namespace ::com::sun::star::beans;
102 : : using namespace ::com::sun::star::uno;
103 : : using namespace ::com::sun::star::linguistic2;
104 : : using namespace ::com::sun::star::smarttags;
105 : :
106 : : /*--------------------------------------------------------------------
107 : : Beschreibung: Lingu-Dispatcher
108 : : --------------------------------------------------------------------*/
109 : 0 : void SwView::ExecLingu(SfxRequest &rReq)
110 : : {
111 [ # # # # : 0 : switch(rReq.GetSlot())
# ]
112 : : {
113 : : case SID_THESAURUS:
114 : 0 : StartThesaurus();
115 : 0 : rReq.Ignore();
116 : 0 : break;
117 : : case SID_HANGUL_HANJA_CONVERSION:
118 : : StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
119 : 0 : i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True );
120 : 0 : break;
121 : : case SID_CHINESE_CONVERSION:
122 : : {
123 : : //open ChineseTranslationDialog
124 : : Reference< XComponentContext > xContext(
125 [ # # ]: 0 : ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
126 [ # # ]: 0 : if(xContext.is())
127 : : {
128 [ # # ][ # # ]: 0 : Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
129 [ # # ]: 0 : if(xMCF.is())
130 : : {
131 : : Reference< ui::dialogs::XExecutableDialog > xDialog(
132 [ # # ]: 0 : xMCF->createInstanceWithContext(
133 : : rtl::OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
134 [ # # ][ # # ]: 0 : , xContext), UNO_QUERY);
135 [ # # ]: 0 : Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
136 [ # # ]: 0 : if( xInit.is() )
137 : : {
138 : : // initialize dialog
139 [ # # ]: 0 : Reference< awt::XWindow > xDialogParentWindow(0);
140 [ # # ]: 0 : Sequence<Any> aSeq(1);
141 [ # # ]: 0 : Any* pArray = aSeq.getArray();
142 : 0 : PropertyValue aParam;
143 : 0 : aParam.Name = rtl::OUString("ParentWindow");
144 [ # # ][ # # ]: 0 : aParam.Value <<= makeAny(xDialogParentWindow);
145 [ # # ][ # # ]: 0 : pArray[0] <<= makeAny(aParam);
146 [ # # ][ # # ]: 0 : xInit->initialize( aSeq );
147 : :
148 : : //execute dialog
149 [ # # ][ # # ]: 0 : sal_Int16 nDialogRet = xDialog->execute();
150 [ # # ]: 0 : if( RET_OK == nDialogRet )
151 : : {
152 : : //get some parameters from the dialog
153 : 0 : sal_Bool bToSimplified = sal_True;
154 : 0 : sal_Bool bUseVariants = sal_True;
155 : 0 : sal_Bool bCommonTerms = sal_True;
156 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
157 [ # # ]: 0 : if( xProp.is() )
158 : : {
159 : : try
160 : : {
161 [ # # ][ # # ]: 0 : xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
[ # # ]
162 [ # # ][ # # ]: 0 : xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
[ # # ]
163 [ # # ][ # # ]: 0 : xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
[ # # ][ # # ]
164 : : }
165 [ # # ]: 0 : catch (const Exception&)
166 : : {
167 : : }
168 : : }
169 : :
170 : : //execute translation
171 [ # # ]: 0 : sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
172 [ # # ]: 0 : sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
173 [ # # ]: 0 : sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
174 [ # # ]: 0 : if( !bCommonTerms )
175 : 0 : nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
176 : :
177 : : Font aTargetFont = GetEditWin().GetDefaultFont( DEFAULTFONT_CJK_TEXT,
178 [ # # ][ # # ]: 0 : nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
[ # # ]
179 : :
180 : : // disallow formatting, updating the view, ... while
181 : : // converting the document. (saves time)
182 : : // Also remember the current view and cursor position for later
183 [ # # ]: 0 : pWrtShell->StartAction();
184 : :
185 : : // remember cursor position data for later restoration of the cursor
186 [ # # ]: 0 : const SwPosition *pPoint = pWrtShell->GetCrsr()->GetPoint();
187 : 0 : sal_Bool bRestoreCursor = pPoint->nNode.GetNode().IsTxtNode();
188 [ # # ]: 0 : const SwNodeIndex aPointNodeIndex( pPoint->nNode );
189 : 0 : xub_StrLen nPointIndex = pPoint->nContent.GetIndex();
190 : :
191 : : // since this conversion is not interactive the whole converted
192 : : // document should be undone in a single undo step.
193 [ # # ]: 0 : pWrtShell->StartUndo( UNDO_OVERWRITE );
194 : :
195 [ # # ]: 0 : StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False );
196 : :
197 [ # # ]: 0 : pWrtShell->EndUndo( UNDO_OVERWRITE );
198 : :
199 [ # # ]: 0 : if (bRestoreCursor)
200 : : {
201 : 0 : SwTxtNode *pTxtNode = aPointNodeIndex.GetNode().GetTxtNode();
202 : : // check for unexpected error case
203 : : OSL_ENSURE( pTxtNode && pTxtNode->GetTxt().Len() >= nPointIndex,
204 : : "text missing: corrupted node?" );
205 [ # # ][ # # ]: 0 : if (!pTxtNode || pTxtNode->GetTxt().Len() < nPointIndex)
[ # # ]
206 : 0 : nPointIndex = 0;
207 : : // restore cursor to its original position
208 [ # # ][ # # ]: 0 : pWrtShell->GetCrsr()->GetPoint()->nContent.Assign( pTxtNode, nPointIndex );
[ # # ]
209 : : }
210 : :
211 : : // enable all, restore view and cursor position
212 [ # # ][ # # ]: 0 : pWrtShell->EndAction();
[ # # ]
213 [ # # ]: 0 : }
214 : : }
215 [ # # ]: 0 : Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
216 [ # # ]: 0 : if( xComponent.is() )
217 [ # # ][ # # ]: 0 : xComponent->dispose();
218 : 0 : }
219 : : }
220 : 0 : break;
221 : : }
222 : : case FN_HYPHENATE_OPT_DLG:
223 : 0 : HyphenateDocument();
224 : 0 : break;
225 : : default:
226 : : OSL_ENSURE(!this, "wrong Dispatcher");
227 : 0 : return;
228 : : }
229 : : }
230 : :
231 : : /*--------------------------------------------------------------------
232 : : Description: start language specific text conversion
233 : : --------------------------------------------------------------------*/
234 : 0 : void SwView::StartTextConversion(
235 : : LanguageType nSourceLang,
236 : : LanguageType nTargetLang,
237 : : const Font *pTargetFont,
238 : : sal_Int32 nOptions,
239 : : sal_Bool bIsInteractive )
240 : : {
241 : : // do not do text conversion if it is active elsewhere
242 [ # # ]: 0 : if (GetWrtShell().HasConvIter())
243 : : {
244 : 0 : return;
245 : : }
246 : :
247 : 0 : SpellKontext(sal_True);
248 : :
249 : 0 : const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
250 : 0 : const sal_Bool bOldIdle = pVOpt->IsIdle();
251 : 0 : pVOpt->SetIdle( sal_False );
252 : :
253 : 0 : sal_Bool bOldIns = pWrtShell->IsInsMode();
254 : 0 : pWrtShell->SetInsMode( sal_True );
255 : :
256 : 0 : sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection() ||
257 [ # # ][ # # ]: 0 : pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
258 : :
259 [ # # ][ # # ]: 0 : sal_Bool bStart = bSelection || pWrtShell->IsStartOfDoc();
260 [ # # ][ # # ]: 0 : sal_Bool bOther = !bSelection && !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
261 : :
262 : : {
263 : : const uno::Reference< lang::XMultiServiceFactory > xMgr(
264 [ # # ]: 0 : comphelper::getProcessServiceFactory() );
265 : : SwHHCWrapper aWrap( this, xMgr, nSourceLang, nTargetLang, pTargetFont,
266 : : nOptions, bIsInteractive,
267 [ # # ]: 0 : bStart, bOther, bSelection );
268 [ # # ][ # # ]: 0 : aWrap.Convert();
269 : : }
270 : :
271 : 0 : pWrtShell->SetInsMode( bOldIns );
272 : 0 : pVOpt->SetIdle( bOldIdle );
273 : 0 : SpellKontext(sal_False);
274 : : }
275 : :
276 : : /*--------------------------------------------------------------------
277 : : spellcheck and text conversion related stuff
278 : : --------------------------------------------------------------------*/
279 : 0 : void SwView::SpellStart( SvxSpellArea eWhich,
280 : : sal_Bool bStartDone, sal_Bool bEndDone,
281 : : SwConversionArgs *pConvArgs )
282 : : {
283 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( ::GetLinguPropertySet() );
284 : 0 : sal_Bool bIsWrapReverse = (!pConvArgs && xProp.is()) ?
285 [ # # # # ]: 0 : *(sal_Bool*)xProp->getPropertyValue( C2U(UPN_IS_WRAP_REVERSE) ).getValue() : sal_False;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
286 : :
287 : 0 : SwDocPositions eStart = DOCPOS_START;
288 : 0 : SwDocPositions eEnde = DOCPOS_END;
289 : 0 : SwDocPositions eCurr = DOCPOS_CURR;
290 [ # # # # : 0 : switch ( eWhich )
# ]
291 : : {
292 : : case SVX_SPELL_BODY:
293 [ # # ]: 0 : if( bIsWrapReverse )
294 : 0 : eCurr = DOCPOS_END;
295 : : else
296 : 0 : eCurr = DOCPOS_START;
297 : 0 : break;
298 : : case SVX_SPELL_BODY_END:
299 [ # # ]: 0 : if( bIsWrapReverse )
300 : : {
301 [ # # ]: 0 : if( bStartDone )
302 : 0 : eStart = DOCPOS_CURR;
303 : 0 : eCurr = DOCPOS_END;
304 : : }
305 [ # # ]: 0 : else if( bStartDone )
306 : 0 : eCurr = DOCPOS_START;
307 : 0 : break;
308 : : case SVX_SPELL_BODY_START:
309 [ # # ]: 0 : if( !bIsWrapReverse )
310 : : {
311 [ # # ]: 0 : if( bEndDone )
312 : 0 : eEnde = DOCPOS_CURR;
313 : 0 : eCurr = DOCPOS_START;
314 : : }
315 [ # # ]: 0 : else if( bEndDone )
316 : 0 : eCurr = DOCPOS_END;
317 : 0 : break;
318 : : case SVX_SPELL_OTHER:
319 [ # # ]: 0 : if( bIsWrapReverse )
320 : : {
321 : 0 : eStart = DOCPOS_OTHERSTART;
322 : 0 : eEnde = DOCPOS_OTHEREND;
323 : 0 : eCurr = DOCPOS_OTHEREND;
324 : : }
325 : : else
326 : : {
327 : 0 : eStart = DOCPOS_OTHERSTART;
328 : 0 : eEnde = DOCPOS_OTHEREND;
329 : 0 : eCurr = DOCPOS_OTHERSTART;
330 : : }
331 : 0 : break;
332 : : default:
333 : : OSL_ENSURE( !this, "SpellStart with unknown Area" );
334 : : }
335 [ # # ]: 0 : pWrtShell->SpellStart( eStart, eEnde, eCurr, pConvArgs );
336 : 0 : }
337 : :
338 : : /*--------------------------------------------------------------------
339 : : Beschreibung: Fehlermeldung beim Spelling
340 : : --------------------------------------------------------------------*/
341 : : // Der uebergebene Pointer nLang ist selbst der Wert
342 : 0 : void SwView::SpellError(LanguageType eLang)
343 : : {
344 : : #if OSL_DEBUG_LEVEL > 1
345 : : sal_Bool bFocus = GetEditWin().HasFocus();
346 : : #endif
347 : 0 : sal_uInt16 nPend = 0;
348 : :
349 [ # # ]: 0 : if ( pWrtShell->ActionPend() )
350 : : {
351 [ # # ]: 0 : pWrtShell->Push();
352 [ # # ]: 0 : pWrtShell->ClearMark();
353 [ # # ]: 0 : do
354 : : {
355 [ # # ]: 0 : pWrtShell->EndAction();
356 : 0 : ++nPend;
357 : : }
358 : 0 : while( pWrtShell->ActionPend() );
359 : : }
360 [ # # ]: 0 : String aErr(SvtLanguageTable::GetLanguageString( eLang ) );
361 : :
362 : 0 : SwEditWin &rEditWin = GetEditWin();
363 : : #if OSL_DEBUG_LEVEL > 1
364 : : bFocus = rEditWin.HasFocus();
365 : : #endif
366 : 0 : sal_uInt16 nWaitCnt = 0;
367 [ # # ][ # # ]: 0 : while( rEditWin.IsWait() )
368 : : {
369 [ # # ]: 0 : rEditWin.LeaveWait();
370 : 0 : ++nWaitCnt;
371 : : }
372 [ # # ]: 0 : if ( LANGUAGE_NONE == eLang )
373 [ # # ]: 0 : ErrorHandler::HandleError( ERRCODE_SVX_LINGU_NOLANGUAGE );
374 : : else
375 [ # # ][ # # ]: 0 : ErrorHandler::HandleError( *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
[ # # ][ # # ]
376 : :
377 [ # # ]: 0 : while( nWaitCnt )
378 : : {
379 [ # # ]: 0 : rEditWin.EnterWait();
380 : 0 : --nWaitCnt;
381 : : }
382 : : #if OSL_DEBUG_LEVEL > 1
383 : : bFocus = GetEditWin().HasFocus();
384 : : #endif
385 : :
386 [ # # ]: 0 : if ( nPend )
387 : : {
388 [ # # ]: 0 : while( nPend-- )
389 [ # # ]: 0 : pWrtShell->StartAction();
390 [ # # ]: 0 : pWrtShell->Combine();
391 [ # # ]: 0 : }
392 : : #if OSL_DEBUG_LEVEL > 1
393 : : if( !bFocus )
394 : : GetEditWin().GrabFocus();
395 : : #endif
396 : :
397 : 0 : }
398 : :
399 : : /*--------------------------------------------------------------------
400 : : Beschreibung: Spelling beenden und Cursor wiederherstellen
401 : : --------------------------------------------------------------------*/
402 : 0 : void SwView::SpellEnd( SwConversionArgs *pConvArgs )
403 : : {
404 : 0 : pWrtShell->SpellEnd( pConvArgs );
405 [ # # ]: 0 : if( pWrtShell->IsExtMode() )
406 : 0 : pWrtShell->SetMark();
407 : 0 : }
408 : :
409 : 0 : void SwView::HyphStart( SvxSpellArea eWhich )
410 : : {
411 [ # # # # : 0 : switch ( eWhich )
# ]
412 : : {
413 : : case SVX_SPELL_BODY:
414 : 0 : pWrtShell->HyphStart( DOCPOS_START, DOCPOS_END );
415 : 0 : break;
416 : : case SVX_SPELL_BODY_END:
417 : 0 : pWrtShell->HyphStart( DOCPOS_CURR, DOCPOS_END );
418 : 0 : break;
419 : : case SVX_SPELL_BODY_START:
420 : 0 : pWrtShell->HyphStart( DOCPOS_START, DOCPOS_CURR );
421 : 0 : break;
422 : : case SVX_SPELL_OTHER:
423 : 0 : pWrtShell->HyphStart( DOCPOS_OTHERSTART, DOCPOS_OTHEREND );
424 : 0 : break;
425 : : default:
426 : : OSL_ENSURE( !this, "HyphStart with unknown Area" );
427 : : }
428 : 0 : }
429 : :
430 : : /*--------------------------------------------------------------------
431 : : Beschreibung: Interaktive Trennung
432 : : --------------------------------------------------------------------*/
433 : 0 : void SwView::HyphenateDocument()
434 : : {
435 : : // do not hyphenate if interactive hyphenationg is active elsewhere
436 [ # # ][ # # ]: 0 : if (GetWrtShell().HasHyphIter())
437 : : {
438 : : MessBox( 0, WB_OK, String( SW_RES( STR_HYPH_TITLE ) ),
439 [ # # ][ # # ]: 0 : String( SW_RES( STR_MULT_INTERACT_HYPH_WARN ) ) ).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
440 : : return;
441 : : }
442 : :
443 : : SfxErrorContext aContext( ERRCTX_SVX_LINGU_HYPHENATION, aEmptyStr, pEditWin,
444 [ # # ][ # # ]: 0 : RID_SVXERRCTX, &DIALOG_MGR() );
445 : :
446 [ # # ]: 0 : Reference< XHyphenator > xHyph( ::GetHyphenator() );
447 [ # # ]: 0 : if (!xHyph.is())
448 : : {
449 [ # # ]: 0 : ErrorHandler::HandleError( ERRCODE_SVX_LINGU_LINGUNOTEXISTS );
450 : : return;
451 : : }
452 : :
453 [ # # ][ # # ]: 0 : if (pWrtShell->GetSelectionType() & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_DRW))
454 : : {
455 : : // Silbentrennung in einem Draw-Objekt
456 [ # # ]: 0 : HyphenateDrawText();
457 : : }
458 : : else
459 : : {
460 : 0 : SwViewOption* pVOpt = (SwViewOption*)pWrtShell->GetViewOptions();
461 : 0 : sal_Bool bOldIdle = pVOpt->IsIdle();
462 : 0 : pVOpt->SetIdle( sal_False );
463 : :
464 [ # # ]: 0 : Reference< beans::XPropertySet > xProp( ::GetLinguPropertySet() );
465 : :
466 : :
467 [ # # ]: 0 : pWrtShell->StartUndo(UNDO_INSATTR); // spaeter gueltig
468 : :
469 : 0 : sal_Bool bHyphSpecial = xProp.is() ?
470 [ # # ][ # # ]: 0 : *(sal_Bool*)xProp->getPropertyValue( C2U(UPN_IS_HYPH_SPECIAL) ).getValue() : sal_False;
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
471 [ # # ]: 0 : sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection() ||
472 [ # # ][ # # ]: 0 : pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
[ # # ][ # # ]
473 [ # # ][ # # ]: 0 : sal_Bool bOther = pWrtShell->HasOtherCnt() && bHyphSpecial && !bSelection;
[ # # ][ # # ]
474 [ # # ][ # # ]: 0 : sal_Bool bStart = bSelection || ( !bOther && pWrtShell->IsStartOfDoc() );
[ # # ][ # # ]
475 : 0 : sal_Bool bStop = sal_False;
476 [ # # ][ # # ]: 0 : if( !bOther && !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY) && !bSelection )
[ # # ][ # # ]
[ # # ]
477 : : // kein Sonderbereich eingeschaltet
478 : : {
479 : : // Ich will auch in Sonderbereichen trennen
480 [ # # ]: 0 : QueryBox aBox( &GetEditWin(), SW_RES( DLG_SPECIAL_FORCED ) );
481 [ # # ][ # # ]: 0 : if( aBox.Execute() == RET_YES )
482 : : {
483 : 0 : bOther = sal_True;
484 [ # # ]: 0 : if (xProp.is())
485 : : {
486 : 0 : sal_Bool bTrue = sal_True;
487 [ # # ]: 0 : Any aTmp(&bTrue, ::getBooleanCppuType());
488 [ # # ][ # # ]: 0 : xProp->setPropertyValue( C2U(UPN_IS_HYPH_SPECIAL), aTmp );
[ # # ]
489 : : }
490 : : }
491 : : else
492 [ # # ]: 0 : bStop = sal_True; // Nein Es wird nicht getrennt
493 : : }
494 : :
495 [ # # ]: 0 : if( !bStop )
496 : : {
497 [ # # ]: 0 : SwHyphWrapper aWrap( this, xHyph, bStart, bOther, bSelection );
498 [ # # ]: 0 : aWrap.SpellDocument();
499 [ # # ][ # # ]: 0 : pWrtShell->EndUndo(UNDO_INSATTR);
500 : : }
501 : 0 : pVOpt->SetIdle( bOldIdle );
502 [ # # ][ # # ]: 0 : }
[ # # ]
503 : : }
504 : :
505 : 0 : bool SwView::IsValidSelectionForThesaurus() const
506 : : {
507 : : // must not be a multi-selection, and if it is a selection it needs
508 : : // to be within a single paragraph
509 : :
510 : 0 : const bool bMultiSel = pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
511 : 0 : const sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection();
512 [ # # ][ # # ]: 0 : return !bMultiSel && (!bSelection || pWrtShell->IsSelOnePara() );
[ # # ]
513 : : }
514 : :
515 : 0 : String SwView::GetThesaurusLookUpText( bool bSelection ) const
516 : : {
517 [ # # ]: 0 : return bSelection ? pWrtShell->GetSelTxt() : pWrtShell->GetCurWord();
518 : : }
519 : :
520 : 0 : void SwView::InsertThesaurusSynonym( const String &rSynonmText, const String &rLookUpText, bool bSelection )
521 : : {
522 : 0 : sal_Bool bOldIns = pWrtShell->IsInsMode();
523 : 0 : pWrtShell->SetInsMode( sal_True );
524 : :
525 : 0 : pWrtShell->StartAllAction();
526 : 0 : pWrtShell->StartUndo(UNDO_DELETE);
527 : :
528 [ # # ]: 0 : if( !bSelection )
529 : : {
530 [ # # ]: 0 : if(pWrtShell->IsEndWrd())
531 : 0 : pWrtShell->Left(CRSR_SKIP_CELLS, sal_False, 1, sal_False );
532 : :
533 : 0 : pWrtShell->SelWrd();
534 : :
535 : : // make sure the selection build later from the data below does not
536 : : // include "in word" character to the left and right in order to
537 : : // preserve those. Therefore count those "in words" in order to modify
538 : : // the selection accordingly.
539 : 0 : const sal_Unicode* pChar = rLookUpText.GetBuffer();
540 : 0 : xub_StrLen nLeft = 0;
541 [ # # ][ # # ]: 0 : while (pChar && *pChar++ == CH_TXTATR_INWORD)
[ # # ]
542 : 0 : ++nLeft;
543 [ # # ]: 0 : pChar = rLookUpText.Len() ? rLookUpText.GetBuffer() + rLookUpText.Len() - 1 : 0;
544 : 0 : xub_StrLen nRight = 0;
545 [ # # ][ # # ]: 0 : while (pChar && *pChar-- == CH_TXTATR_INWORD)
[ # # ]
546 : 0 : ++nRight;
547 : :
548 : : // adjust existing selection
549 : 0 : SwPaM *pCrsr = pWrtShell->GetCrsr();
550 : 0 : pCrsr->GetPoint()->nContent -= nRight;
551 : 0 : pCrsr->GetMark()->nContent += nLeft;
552 : : }
553 : :
554 : 0 : pWrtShell->Insert( rSynonmText );
555 : :
556 : 0 : pWrtShell->EndUndo(UNDO_DELETE);
557 : 0 : pWrtShell->EndAllAction();
558 : :
559 : 0 : pWrtShell->SetInsMode( bOldIns );
560 : 0 : }
561 : :
562 : : /*--------------------------------------------------------------------
563 : : Beschreibung: Thesaurus starten
564 : : --------------------------------------------------------------------*/
565 : 0 : void SwView::StartThesaurus()
566 : : {
567 [ # # ][ # # ]: 0 : if (!IsValidSelectionForThesaurus())
568 : : return;
569 : :
570 : : SfxErrorContext aContext( ERRCTX_SVX_LINGU_THESAURUS, aEmptyStr, pEditWin,
571 [ # # ][ # # ]: 0 : RID_SVXERRCTX, &DIALOG_MGR() );
572 : :
573 : : // Sprache rausholen
574 : : //
575 [ # # ]: 0 : LanguageType eLang = pWrtShell->GetCurLang();
576 [ # # ]: 0 : if( LANGUAGE_SYSTEM == eLang )
577 [ # # ]: 0 : eLang = GetAppLanguage();
578 : :
579 [ # # ][ # # ]: 0 : if( eLang == LANGUAGE_DONTKNOW || eLang == LANGUAGE_NONE )
580 : : {
581 [ # # ]: 0 : SpellError( LANGUAGE_NONE );
582 : : return;
583 : : }
584 : :
585 : 0 : SwViewOption* pVOpt = (SwViewOption*)pWrtShell->GetViewOptions();
586 : 0 : sal_Bool bOldIdle = pVOpt->IsIdle();
587 : 0 : pVOpt->SetIdle( sal_False );
588 : :
589 : : // get initial LookUp text
590 [ # # ]: 0 : const sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection();
591 [ # # ]: 0 : String aTmp = GetThesaurusLookUpText( bSelection );
592 : :
593 [ # # ]: 0 : Reference< XThesaurus > xThes( ::GetThesaurus() );
594 : 0 : AbstractThesaurusDialog *pDlg = NULL;
595 : :
596 [ # # ][ # # ]: 0 : if ( !xThes.is() || !xThes->hasLocale( SvxCreateLocale( eLang ) ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
597 [ # # ]: 0 : SpellError( eLang );
598 : : else
599 : : {
600 : : // create dialog
601 : : { //Scope for SwWait-Object
602 [ # # ][ # # ]: 0 : SwWait aWait( *GetDocShell(), sal_True );
603 : : // load library with dialog only on demand ...
604 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
605 [ # # ][ # # ]: 0 : pDlg = pFact->CreateThesaurusDialog( &GetEditWin(), xThes, aTmp, eLang );
606 : : }
607 : :
608 [ # # ][ # # ]: 0 : if ( pDlg->Execute()== RET_OK )
609 [ # # ][ # # ]: 0 : InsertThesaurusSynonym( pDlg->GetWord(), aTmp, bSelection );
[ # # ]
610 : : }
611 : :
612 [ # # ][ # # ]: 0 : delete pDlg;
613 : :
614 [ # # ][ # # ]: 0 : pVOpt->SetIdle( bOldIdle );
[ # # ]
615 : : }
616 : :
617 : : /*--------------------------------------------------------------------
618 : : Beschreibung: Online-Vorschlaege anbieten
619 : : *--------------------------------------------------------------------*/
620 : : //!! Start of extra code for context menu modifying extensions
621 [ # # ][ # # ]: 0 : struct ExecuteInfo
622 : : {
623 : : uno::Reference< frame::XDispatch > xDispatch;
624 : : util::URL aTargetURL;
625 : : uno::Sequence< PropertyValue > aArgs;
626 : : };
627 : :
628 : : class AsyncExecute
629 : : {
630 : : public:
631 : : DECL_STATIC_LINK( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo* );
632 : : };
633 : :
634 : 0 : IMPL_STATIC_LINK_NOINSTANCE( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
635 : : {
636 : 0 : const sal_uInt32 nRef = Application::ReleaseSolarMutex();
637 : : try
638 : : {
639 : : // Asynchronous execution as this can lead to our own destruction!
640 : : // Framework can recycle our current frame and the layout manager disposes all user interface
641 : : // elements if a component gets detached from its frame!
642 [ # # ][ # # ]: 0 : pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
643 : : }
644 : 0 : catch (const Exception&)
645 : : {
646 : : }
647 : :
648 : 0 : Application::AcquireSolarMutex( nRef );
649 [ # # ]: 0 : delete pExecuteInfo;
650 [ # # ]: 0 : return 0;
651 : : }
652 : : //!! End of extra code for context menu modifying extensions
653 : :
654 : 0 : sal_Bool SwView::ExecSpellPopup(const Point& rPt)
655 : : {
656 : 0 : sal_Bool bRet = sal_False;
657 : 0 : const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
658 [ # # ]: 0 : if( pVOpt->IsOnlineSpell() &&
[ # # # # ]
659 : 0 : !pWrtShell->IsSelection())
660 : : {
661 [ # # ]: 0 : if (pWrtShell->GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
662 : 0 : bRet = ExecDrwTxtSpellPopup(rPt);
663 [ # # ]: 0 : else if (!pWrtShell->IsSelFrmMode())
664 : : {
665 : 0 : const sal_Bool bOldViewLock = pWrtShell->IsViewLocked();
666 : 0 : pWrtShell->LockView( sal_True );
667 [ # # ]: 0 : pWrtShell->Push();
668 : 0 : SwRect aToFill;
669 : :
670 : : // decide which variant of the context menu to use...
671 : : // if neither spell checking nor grammar checking provides suggestions use the
672 : : // default context menu.
673 : 0 : bool bUseGrammarContext = false;
674 [ # # ]: 0 : Reference< XSpellAlternatives > xAlt( pWrtShell->GetCorrection(&rPt, aToFill) );
675 [ # # ]: 0 : ProofreadingResult aGrammarCheckRes;
676 : 0 : sal_Int32 nErrorInResult = -1;
677 [ # # ]: 0 : uno::Sequence< rtl::OUString > aSuggestions;
678 : 0 : bool bCorrectionRes = false;
679 [ # # ][ # # ]: 0 : if (!xAlt.is() || xAlt->getAlternatives().getLength() == 0)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
680 : : {
681 : 0 : sal_Int32 nErrorPosInText = -1;
682 [ # # ]: 0 : bCorrectionRes = pWrtShell->GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, &rPt, aToFill );
683 : 0 : ::rtl::OUString aMessageText;
684 [ # # ]: 0 : if (nErrorInResult >= 0)
685 [ # # ]: 0 : aMessageText = aGrammarCheckRes.aErrors[ nErrorInResult ].aShortComment;
686 : : // we like to use the grammar checking context menu if we either get
687 : : // some suggestions or at least a comment about the error found...
688 : : bUseGrammarContext = bCorrectionRes &&
689 [ # # ][ # # ]: 0 : (aSuggestions.getLength() > 0 || !aMessageText.isEmpty());
[ # # ]
690 : : }
691 : :
692 : : // open respective context menu for spell check or grammar errors with correction suggestions...
693 [ # # ][ # # ]: 0 : if ((!bUseGrammarContext && xAlt.is()) ||
[ # # ]
[ # # # # ]
[ # # ]
694 : 0 : (bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aErrors.getLength() > 0))
695 : : {
696 : : // get paragraph text
697 [ # # ]: 0 : String aParaText;
698 [ # # ][ # # ]: 0 : SwPosition aPoint( *pWrtShell->GetCrsr()->GetPoint() );
699 : : const SwTxtNode *pNode = dynamic_cast< const SwTxtNode * >(
700 [ # # ]: 0 : &aPoint.nNode.GetNode() );
701 [ # # ]: 0 : if (pNode)
702 [ # # ]: 0 : aParaText = pNode->GetTxt(); // this may include hidden text but that should be Ok
703 : : else
704 : : {
705 : : OSL_FAIL("text node expected but not found" );
706 : : }
707 : :
708 : 0 : bRet = sal_True;
709 [ # # ]: 0 : pWrtShell->SttSelect();
710 : 0 : std::auto_ptr< SwSpellPopup > pPopup;
711 [ # # ]: 0 : if (bUseGrammarContext)
712 : : {
713 : 0 : sal_Int32 nPos = aPoint.nContent.GetIndex();
714 : : (void) nPos;
715 [ # # ][ # # ]: 0 : pPopup = std::auto_ptr< SwSpellPopup >(new SwSpellPopup( pWrtShell, aGrammarCheckRes, nErrorInResult, aSuggestions, aParaText ));
[ # # ]
716 : : }
717 : : else
718 [ # # ][ # # ]: 0 : pPopup = std::auto_ptr< SwSpellPopup >(new SwSpellPopup( pWrtShell, xAlt, aParaText ));
[ # # ]
719 [ # # ]: 0 : ui::ContextMenuExecuteEvent aEvent;
720 [ # # ]: 0 : const Point aPixPos = GetEditWin().LogicToPixel( rPt );
721 : :
722 [ # # ][ # # ]: 0 : aEvent.SourceWindow = VCLUnoHelper::GetInterface( pEditWin );
723 : 0 : aEvent.ExecutePosition.X = aPixPos.X();
724 : 0 : aEvent.ExecutePosition.Y = aPixPos.Y();
725 : 0 : Menu* pMenu = 0;
726 : :
727 : : ::rtl::OUString sMenuName = bUseGrammarContext ?
728 [ # # ][ # # ]: 0 : OUString("private:resource/GrammarContextMenu") : OUString("private:resource/SpellContextMenu");
[ # # ]
729 [ # # ][ # # ]: 0 : if(TryContextMenuInterception( *pPopup, sMenuName, pMenu, aEvent ))
[ # # ][ # # ]
730 : : {
731 : :
732 : : //! happy hacking for context menu modifying extensions of this
733 : : //! 'custom made' menu... *sigh* (code copied from sfx2 and framework)
734 [ # # ]: 0 : if ( pMenu )
735 : : {
736 [ # # ]: 0 : sal_uInt16 nId = ((PopupMenu*)pMenu)->Execute(pEditWin, aPixPos);
737 [ # # ][ # # ]: 0 : OUString aCommand = ((PopupMenu*)pMenu)->GetItemCommand(nId);
738 [ # # ]: 0 : if (aCommand.isEmpty() )
739 : : {
740 [ # # ][ # # ]: 0 : if(!ExecuteMenuCommand( *dynamic_cast<PopupMenu*>(pMenu), *GetViewFrame(), nId ))
[ # # ]
741 [ # # ]: 0 : pPopup->Execute(nId);
742 : : }
743 : : else
744 : : {
745 : 0 : SfxViewFrame *pSfxViewFrame = GetViewFrame();
746 : 0 : uno::Reference< frame::XFrame > xFrame;
747 [ # # ]: 0 : if ( pSfxViewFrame )
748 [ # # ][ # # ]: 0 : xFrame = pSfxViewFrame->GetFrame().GetFrameInterface();
[ # # ]
749 : 0 : com::sun::star::util::URL aURL;
750 [ # # ]: 0 : uno::Reference< frame::XDispatchProvider > xDispatchProvider( xFrame, UNO_QUERY );
751 : :
752 : : try
753 : : {
754 : 0 : uno::Reference< frame::XDispatch > xDispatch;
755 [ # # ][ # # ]: 0 : uno::Reference< util::XURLTransformer > xURLTransformer = util::URLTransformer::create(comphelper::getProcessComponentContext());
756 : :
757 : 0 : aURL.Complete = aCommand;
758 [ # # ][ # # ]: 0 : xURLTransformer->parseStrict(aURL);
759 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aArgs;
760 [ # # ][ # # ]: 0 : xDispatch = xDispatchProvider->queryDispatch( aURL, rtl::OUString(), 0 );
[ # # ]
761 : :
762 : :
763 [ # # ]: 0 : if (xDispatch.is())
764 : : {
765 : : // Execute dispatch asynchronously
766 [ # # ][ # # ]: 0 : ExecuteInfo* pExecuteInfo = new ExecuteInfo;
767 [ # # ]: 0 : pExecuteInfo->xDispatch = xDispatch;
768 : 0 : pExecuteInfo->aTargetURL = aURL;
769 [ # # ]: 0 : pExecuteInfo->aArgs = aArgs;
770 [ # # ][ # # ]: 0 : Application::PostUserEvent( STATIC_LINK(0, AsyncExecute , ExecuteHdl_Impl), pExecuteInfo );
771 [ # # ][ # # ]: 0 : }
772 : : }
773 [ # # ]: 0 : catch (const Exception&)
774 : : {
775 : 0 : }
776 : 0 : }
777 : : }
778 : : else
779 : : {
780 [ # # ][ # # ]: 0 : pPopup->Execute( aToFill.SVRect(), pEditWin );
781 : : }
782 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
783 : : }
784 : :
785 [ # # ]: 0 : pWrtShell->Pop( sal_False );
786 [ # # ][ # # ]: 0 : pWrtShell->LockView( bOldViewLock );
787 : : }
788 : : }
789 : 0 : return bRet;
790 : : }
791 : :
792 : : /** Function: ExecSmartTagPopup
793 : :
794 : : This function shows the popup menu for smarttag
795 : : actions.
796 : : */
797 : 0 : sal_Bool SwView::ExecSmartTagPopup( const Point& rPt )
798 : : {
799 : 0 : sal_Bool bRet = sal_False;
800 : 0 : const sal_Bool bOldViewLock = pWrtShell->IsViewLocked();
801 : 0 : pWrtShell->LockView( sal_True );
802 [ # # ]: 0 : pWrtShell->Push();
803 : :
804 : :
805 : : // get word that was clicked on
806 : : // This data structure maps a smart tag type string to the property bag
807 : 0 : SwRect aToFill;
808 [ # # ]: 0 : Sequence< rtl::OUString > aSmartTagTypes;
809 [ # # ]: 0 : Sequence< Reference< container::XStringKeyMap > > aStringKeyMaps;
810 : 0 : Reference<text::XTextRange> xRange;
811 : :
812 [ # # ]: 0 : pWrtShell->GetSmartTagTerm( rPt, aToFill, aSmartTagTypes, aStringKeyMaps, xRange);
813 [ # # ][ # # ]: 0 : if ( xRange.is() && aSmartTagTypes.getLength() )
[ # # ]
814 : : {
815 : 0 : bRet = sal_True;
816 [ # # ]: 0 : pWrtShell->SttSelect();
817 [ # # ]: 0 : SwSmartTagPopup aPopup( this, aSmartTagTypes, aStringKeyMaps, xRange );
818 [ # # ][ # # ]: 0 : aPopup.Execute( aToFill.SVRect(), pEditWin );
[ # # ]
819 : : }
820 : :
821 [ # # ]: 0 : pWrtShell->Pop( sal_False );
822 : 0 : pWrtShell->LockView( bOldViewLock );
823 : :
824 [ # # ][ # # ]: 0 : return bRet;
825 : : }
826 : :
827 [ # # ][ # # ]: 0 : class SwFieldDialog : public FloatingWindow
828 : : {
829 : : private:
830 : : ListBox aListBox;
831 : : IFieldmark *pFieldmark;
832 : :
833 : : DECL_LINK( MyListBoxHandler, ListBox * );
834 : :
835 : : public:
836 : : SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM );
837 : : };
838 : :
839 : 0 : SwFieldDialog::SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ) :
840 : : FloatingWindow( parent, WB_BORDER | WB_SYSTEMWINDOW ),
841 : : aListBox(this),
842 [ # # ]: 0 : pFieldmark( fieldBM )
843 : : {
844 [ # # ]: 0 : if ( fieldBM != NULL )
845 : : {
846 [ # # ]: 0 : const IFieldmark::parameter_map_t* const pParameters = fieldBM->GetParameters();
847 : :
848 : 0 : rtl::OUString sListKey = rtl::OUString( ODF_FORMDROPDOWN_LISTENTRY );
849 [ # # ]: 0 : IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find( sListKey );
850 [ # # ]: 0 : if(pListEntries != pParameters->end())
851 : : {
852 [ # # ]: 0 : Sequence< ::rtl::OUString > vListEntries;
853 [ # # ]: 0 : pListEntries->second >>= vListEntries;
854 [ # # ][ # # ]: 0 : for( ::rtl::OUString* pCurrent = vListEntries.getArray();
855 [ # # ]: 0 : pCurrent != vListEntries.getArray() + vListEntries.getLength();
856 : : ++pCurrent)
857 : : {
858 [ # # ][ # # ]: 0 : aListBox.InsertEntry(*pCurrent);
[ # # ]
859 [ # # ]: 0 : }
860 : : }
861 : :
862 : : // Select the current one
863 : 0 : rtl::OUString sResultKey = rtl::OUString( ODF_FORMDROPDOWN_RESULT );
864 [ # # ]: 0 : IFieldmark::parameter_map_t::const_iterator pResult = pParameters->find( sResultKey );
865 [ # # ]: 0 : if ( pResult != pParameters->end() )
866 : : {
867 : 0 : sal_Int32 nSelection = -1;
868 : 0 : pResult->second >>= nSelection;
869 [ # # ]: 0 : aListBox.SelectEntryPos( nSelection );
870 : 0 : }
871 : : }
872 : :
873 [ # # ]: 0 : Size lbSize=aListBox.GetOptimalSize(WINDOWSIZE_PREFERRED);
874 : 0 : lbSize.Width()+=50;
875 : 0 : lbSize.Height()+=20;
876 [ # # ]: 0 : aListBox.SetSizePixel(lbSize);
877 [ # # ]: 0 : aListBox.SetSelectHdl( LINK( this, SwFieldDialog, MyListBoxHandler ) );
878 [ # # ]: 0 : aListBox.Show();
879 : :
880 [ # # ]: 0 : SetSizePixel( lbSize );
881 : 0 : }
882 : :
883 : 0 : IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox *, pBox )
884 : : {
885 : 0 : short res = 0;
886 [ # # ]: 0 : if ( !pBox->IsTravelSelect() )
887 : : {
888 [ # # ]: 0 : sal_Int32 selection = pBox->GetSelectEntryPos();
889 [ # # ]: 0 : if ( selection >= 0 )
890 : : {
891 : 0 : rtl::OUString sKey = rtl::OUString( ODF_FORMDROPDOWN_RESULT );
892 [ # # ][ # # ]: 0 : (*pFieldmark->GetParameters())[ sKey ] = makeAny(selection);
[ # # ]
893 [ # # ]: 0 : pFieldmark->Invalidate();
894 [ # # ]: 0 : SwView& rView = ( ( SwEditWin* )GetParent() )->GetView();
895 [ # # ][ # # ]: 0 : rView.GetDocShell()->SetModified( sal_True );
896 : : }
897 : :
898 [ # # ]: 0 : EndPopupMode();
899 : 0 : res = 1;
900 : : }
901 : 0 : return res;
902 : : }
903 : :
904 : 0 : IMPL_LINK_NOARG(SwView, FieldPopupModeEndHdl)
905 : : {
906 [ # # ]: 0 : if ( mpFieldPopup )
907 : : {
908 [ # # ]: 0 : delete mpFieldPopup;
909 : 0 : mpFieldPopup = NULL;
910 : : }
911 : 0 : return 0;
912 : : }
913 : :
914 : 0 : void SwView::ExecFieldPopup( const Point& rPt, IFieldmark *fieldBM )
915 : : {
916 [ # # ]: 0 : const Point aPixPos = GetEditWin().LogicToPixel( rPt );
917 : :
918 [ # # ][ # # ]: 0 : mpFieldPopup = new SwFieldDialog( pEditWin, fieldBM );
919 [ # # ]: 0 : mpFieldPopup->SetPopupModeEndHdl( LINK( this, SwView, FieldPopupModeEndHdl ) );
920 : :
921 [ # # ][ # # ]: 0 : Rectangle aRect( pEditWin->OutputToScreenPixel( aPixPos ), Size( 0, 0 ) );
922 [ # # ]: 0 : mpFieldPopup->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS );
923 : 0 : }
924 : :
925 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|