Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <hintids.hxx>
22 : #include <i18nlangtag/lang.h>
23 : #include <svl/slstitm.hxx>
24 : #include <svl/cjkoptions.hxx>
25 : #include <editeng/fontitem.hxx>
26 : #include <editeng/langitem.hxx>
27 : #include <svx/svdview.hxx>
28 : #include <vcl/msgbox.hxx>
29 : #include <sfx2/viewfrm.hxx>
30 : #include <sfx2/objface.hxx>
31 : #include <svx/svdotext.hxx>
32 : #include <editeng/editeng.hxx>
33 : #include <editeng/editview.hxx>
34 : #include <editeng/eeitem.hxx>
35 : #include <editeng/scripttypeitem.hxx>
36 : #include <sfx2/bindings.hxx>
37 : #include <svx/fontwork.hxx>
38 : #include <sfx2/request.hxx>
39 : #include <sfx2/sidebar/EnumContext.hxx>
40 : #include <svl/whiter.hxx>
41 : #include <editeng/outliner.hxx>
42 : #include <editeng/editstat.hxx>
43 : #include <svx/svdoutl.hxx>
44 : #include <com/sun/star/i18n/TransliterationModules.hpp>
45 : #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
46 : #include <com/sun/star/i18n/TextConversionOption.hpp>
47 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
48 : #include <com/sun/star/lang/XInitialization.hpp>
49 : #include <swtypes.hxx>
50 : #include <view.hxx>
51 : #include <wrtsh.hxx>
52 : #include <viewopt.hxx>
53 : #include <initui.hxx> // for SpellPointer
54 : #include <drwtxtsh.hxx>
55 : #include <swundo.hxx>
56 : #include <breakit.hxx>
57 :
58 : #include <cmdid.h>
59 : #include <helpid.h>
60 : #include <globals.hrc>
61 : #include <shells.hrc>
62 :
63 : #define SwDrawTextShell
64 : #include <sfx2/msg.hxx>
65 : #include <swslots.hxx>
66 : #include <popup.hrc>
67 : #include <uitool.hxx>
68 : #include <wview.hxx>
69 : #include <swmodule.hxx>
70 : #include <svx/dialogs.hrc>
71 : #include <svx/svdoashp.hxx>
72 : #include <svx/svxdlg.hxx>
73 : #include <svx/xtable.hxx>
74 : #include <cppuhelper/bootstrap.hxx>
75 : #include "swabstdlg.hxx"
76 : #include "misc.hrc"
77 :
78 : using namespace ::com::sun::star;
79 : using namespace ::com::sun::star::uno;
80 : using namespace ::com::sun::star::beans;
81 : using namespace ::com::sun::star::i18n;
82 :
83 198 : SFX_IMPL_INTERFACE(SwDrawTextShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
84 : {
85 33 : SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRWTXT_POPUPMENU));
86 33 : SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TEXT_TOOLBOX));
87 33 : SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
88 33 : }
89 :
90 18 : TYPEINIT1(SwDrawTextShell,SfxShell)
91 :
92 0 : void SwDrawTextShell::Init()
93 : {
94 0 : SwWrtShell &rSh = GetShell();
95 0 : pSdrView = rSh.GetDrawView();
96 0 : SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
97 : //#97471# mouse click _and_ key input at the same time
98 0 : if( !pOutliner )
99 0 : return ;
100 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
101 0 : sal_uLong nCtrl = pOutliner->GetControlWord();
102 0 : nCtrl |= EE_CNTRL_AUTOCORRECT;
103 :
104 0 : SetUndoManager(&pOutliner->GetUndoManager());
105 :
106 : // Now let's try an AutoSpell.
107 :
108 0 : const SwViewOption* pVOpt = rSh.GetViewOptions();
109 0 : if(pVOpt->IsOnlineSpell())
110 : {
111 0 : nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
112 : }
113 : else
114 0 : nCtrl &= ~(EE_CNTRL_ONLINESPELLING);
115 :
116 0 : pOutliner->SetControlWord(nCtrl);
117 0 : pOLV->ShowCursor();
118 : }
119 :
120 0 : SwDrawTextShell::SwDrawTextShell(SwView &rV) :
121 : SfxShell(&rV),
122 0 : rView(rV)
123 : {
124 0 : SwWrtShell &rSh = GetShell();
125 0 : SetPool(rSh.GetAttrPool().GetSecondaryPool());
126 :
127 0 : Init();
128 :
129 0 : rSh.NoEdit(true);
130 0 : SetName(OUString("ObjectText"));
131 0 : SetHelpId(SW_DRWTXTSHELL);
132 0 : SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText));
133 0 : }
134 :
135 0 : SwDrawTextShell::~SwDrawTextShell()
136 : {
137 0 : if ( GetView().GetCurShell() == this )
138 0 : rView.ResetSubShell();
139 0 : }
140 :
141 0 : SwWrtShell& SwDrawTextShell::GetShell()
142 : {
143 0 : return rView.GetWrtShell();
144 : }
145 :
146 : // Disable slots with this status method
147 :
148 0 : void SwDrawTextShell::StateDisableItems( SfxItemSet &rSet )
149 : {
150 0 : SfxWhichIter aIter(rSet);
151 0 : sal_uInt16 nWhich = aIter.FirstWhich();
152 :
153 0 : while (nWhich)
154 : {
155 0 : rSet.DisableItem( nWhich );
156 0 : nWhich = aIter.NextWhich();
157 0 : }
158 0 : }
159 :
160 0 : void SwDrawTextShell::SetAttrToMarked(const SfxItemSet& rAttr)
161 : {
162 0 : Rectangle aNullRect;
163 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
164 0 : Rectangle aOutRect = pOLV->GetOutputArea();
165 :
166 0 : if (aNullRect != aOutRect)
167 : {
168 0 : GetShell().GetDrawView()->SetAttributes(rAttr);
169 : // Init();
170 : }
171 0 : }
172 :
173 0 : sal_Bool SwDrawTextShell::IsTextEdit()
174 : {
175 0 : return pSdrView->IsTextEdit();
176 : }
177 :
178 0 : void SwDrawTextShell::ExecFontWork(SfxRequest& rReq)
179 : {
180 0 : SwWrtShell &rSh = GetShell();
181 0 : FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
182 0 : SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
183 0 : SfxViewFrame* pVFrame = GetView().GetViewFrame();
184 0 : if ( rReq.GetArgs() )
185 : {
186 0 : pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
187 0 : ((const SfxBoolItem&) (rReq.GetArgs()->
188 0 : Get(SID_FONTWORK))).GetValue());
189 : }
190 : else
191 0 : pVFrame->ToggleChildWindow(SvxFontWorkChildWindow::GetChildWindowId());
192 :
193 0 : pVFrame->GetBindings().Invalidate(SID_FONTWORK);
194 0 : }
195 :
196 0 : void SwDrawTextShell::StateFontWork(SfxItemSet& rSet)
197 : {
198 0 : const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
199 0 : rSet.Put(SfxBoolItem(SID_FONTWORK, GetView().GetViewFrame()->HasChildWindow(nId)));
200 0 : }
201 :
202 : // Edit SfxRequests for FontWork
203 :
204 0 : void SwDrawTextShell::ExecFormText(SfxRequest& rReq)
205 : {
206 0 : SwWrtShell &rSh = GetShell();
207 0 : SdrView* pDrView = rSh.GetDrawView();
208 :
209 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
210 :
211 0 : if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
212 : {
213 0 : const SfxItemSet& rSet = *rReq.GetArgs();
214 :
215 0 : if ( pDrView->IsTextEdit() )
216 : {
217 : //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and
218 : // 'this' is not valid anymore
219 0 : SwView& rTempView = GetView();
220 0 : pDrView->SdrEndTextEdit(sal_True);
221 : //this removes the current shell from the dispatcher stack!!
222 0 : rTempView.AttrChangedNotify(&rSh);
223 : }
224 :
225 0 : pDrView->SetAttributes(rSet);
226 : }
227 :
228 0 : }
229 :
230 : // Return Status values back to FontWork
231 :
232 0 : void SwDrawTextShell::GetFormTextState(SfxItemSet& rSet)
233 : {
234 0 : SwWrtShell &rSh = GetShell();
235 0 : SdrView* pDrView = rSh.GetDrawView();
236 0 : const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
237 0 : const SdrObject* pObj = NULL;
238 0 : SvxFontWorkDialog* pDlg = NULL;
239 :
240 0 : const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
241 :
242 0 : SfxViewFrame* pVFrame = GetView().GetViewFrame();
243 0 : if ( pVFrame->HasChildWindow(nId) )
244 0 : pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
245 :
246 0 : if ( rMarkList.GetMarkCount() == 1 )
247 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
248 :
249 0 : const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
250 : const bool bDeactivate(
251 0 : !pObj ||
252 0 : !pTextObj ||
253 0 : !pTextObj->HasText() ||
254 0 : dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
255 :
256 0 : if (bDeactivate)
257 : {
258 0 : rSet.DisableItem(XATTR_FORMTXTSTYLE);
259 0 : rSet.DisableItem(XATTR_FORMTXTADJUST);
260 0 : rSet.DisableItem(XATTR_FORMTXTDISTANCE);
261 0 : rSet.DisableItem(XATTR_FORMTXTSTART);
262 0 : rSet.DisableItem(XATTR_FORMTXTMIRROR);
263 0 : rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
264 0 : rSet.DisableItem(XATTR_FORMTXTOUTLINE);
265 0 : rSet.DisableItem(XATTR_FORMTXTSHADOW);
266 0 : rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
267 0 : rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
268 0 : rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
269 : }
270 : else
271 : {
272 0 : if ( pDlg )
273 0 : pDlg->SetColorList(XColorList::GetStdColorList());
274 :
275 0 : pDrView->GetAttributes( rSet );
276 : }
277 0 : }
278 :
279 0 : void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq)
280 : {
281 0 : SwWrtShell &rSh = GetShell();
282 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
283 0 : if( rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() )
284 : {
285 0 : switch(rReq.GetSlot())
286 : {
287 : case SID_THESAURUS:
288 0 : pOLV->StartThesaurus();
289 0 : break;
290 :
291 : case SID_HANGUL_HANJA_CONVERSION:
292 : pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
293 0 : i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False );
294 0 : break;
295 :
296 : case SID_CHINESE_CONVERSION:
297 : {
298 : //open ChineseTranslationDialog
299 : Reference< XComponentContext > xContext(
300 0 : ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
301 0 : if(xContext.is())
302 : {
303 0 : Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
304 0 : if(xMCF.is())
305 : {
306 : Reference< ui::dialogs::XExecutableDialog > xDialog(
307 0 : xMCF->createInstanceWithContext(
308 : OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
309 0 : , xContext), UNO_QUERY);
310 0 : Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
311 0 : if( xInit.is() )
312 : {
313 : // initialize dialog
314 0 : Reference< awt::XWindow > xDialogParentWindow(0);
315 0 : Sequence<Any> aSeq(1);
316 0 : Any* pArray = aSeq.getArray();
317 0 : PropertyValue aParam;
318 0 : aParam.Name = OUString("ParentWindow");
319 0 : aParam.Value <<= makeAny(xDialogParentWindow);
320 0 : pArray[0] <<= makeAny(aParam);
321 0 : xInit->initialize( aSeq );
322 :
323 : //execute dialog
324 0 : sal_Int16 nDialogRet = xDialog->execute();
325 0 : if( RET_OK == nDialogRet )
326 : {
327 : //get some parameters from the dialog
328 0 : sal_Bool bToSimplified = sal_True;
329 0 : sal_Bool bUseVariants = sal_True;
330 0 : sal_Bool bCommonTerms = sal_True;
331 0 : Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
332 0 : if( xProp.is() )
333 : {
334 : try
335 : {
336 0 : xProp->getPropertyValue( "IsDirectionToSimplified" ) >>= bToSimplified;
337 0 : xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants;
338 0 : xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms;
339 : }
340 0 : catch (const Exception&)
341 : {
342 : }
343 : }
344 :
345 : //execute translation
346 0 : sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
347 0 : sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
348 0 : sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
349 0 : if( !bCommonTerms )
350 0 : nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
351 :
352 0 : Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
353 0 : nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
354 :
355 0 : pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False );
356 0 : }
357 : }
358 0 : Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
359 0 : if( xComponent.is() )
360 0 : xComponent->dispose();
361 0 : }
362 0 : }
363 : }
364 0 : break;
365 :
366 : default:
367 : OSL_ENSURE(!this, "unexpected slot-id");
368 : }
369 : }
370 0 : }
371 :
372 0 : void SwDrawTextShell::ExecDraw(SfxRequest &rReq)
373 : {
374 0 : SwWrtShell &rSh = GetShell();
375 0 : pSdrView = rSh.GetDrawView();
376 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
377 :
378 0 : switch (rReq.GetSlot())
379 : {
380 : case FN_INSERT_SOFT_HYPHEN:
381 : case FN_INSERT_HARDHYPHEN:
382 : case FN_INSERT_HARD_SPACE:
383 : case SID_INSERT_RLM :
384 : case SID_INSERT_LRM :
385 : case SID_INSERT_ZWNBSP :
386 : case SID_INSERT_ZWSP:
387 : {
388 0 : sal_Unicode cIns = 0;
389 0 : switch(rReq.GetSlot())
390 : {
391 0 : case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
392 0 : case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
393 0 : case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
394 0 : case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
395 0 : case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
396 0 : case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
397 0 : case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
398 : }
399 0 : pOLV->InsertText( OUString(cIns));
400 0 : rReq.Done();
401 : }
402 0 : break;
403 : case SID_CHARMAP:
404 : { // Insert special character
405 0 : InsertSymbol(rReq);
406 0 : break;
407 : }
408 : case FN_INSERT_STRING:
409 : {
410 0 : const SfxItemSet *pNewAttrs = rReq.GetArgs();
411 0 : sal_uInt16 nSlot = rReq.GetSlot();
412 0 : const SfxPoolItem* pItem = 0;
413 0 : if(pNewAttrs)
414 : {
415 0 : pNewAttrs->GetItemState(nSlot, sal_False, &pItem );
416 0 : pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
417 : }
418 0 : break;
419 : }
420 :
421 : case SID_SELECTALL:
422 : {
423 0 : SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
424 0 : if(pOutliner)
425 : {
426 0 : sal_Int32 nParaCount = pOutliner->GetParagraphCount();
427 0 : if (nParaCount > 0)
428 0 : pOLV->SelectRange(0L, nParaCount );
429 : }
430 : }
431 0 : break;
432 :
433 : case FN_FORMAT_RESET: // delete hard text attributes
434 : {
435 0 : pOLV->RemoveAttribsKeepLanguages( true );
436 0 : pOLV->GetEditView().GetEditEngine()->RemoveFields(sal_True);
437 0 : rReq.Done();
438 : }
439 0 : break;
440 :
441 : case FN_ESCAPE:
442 0 : if (pSdrView->IsTextEdit())
443 : {
444 : // Shell switch!
445 0 : rSh.EndTextEdit();
446 0 : SwView& rTempView = rSh.GetView();
447 0 : rTempView.ExitDraw();
448 0 : rSh.Edit();
449 0 : return;
450 : }
451 0 : break;
452 : case FN_DRAWTEXT_ATTR_DLG:
453 : {
454 0 : SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() );
455 0 : pSdrView->GetAttributes( aNewAttr );
456 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
457 0 : if ( pFact )
458 : {
459 : SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog(
460 0 : &(GetView().GetViewFrame()->GetWindow()),
461 0 : &aNewAttr, pSdrView );
462 0 : sal_uInt16 nResult = pDlg->Execute();
463 :
464 0 : if (nResult == RET_OK)
465 : {
466 0 : if (pSdrView->AreObjectsMarked())
467 : {
468 0 : pSdrView->SetAttributes(*pDlg->GetOutputItemSet());
469 0 : rReq.Done(*(pDlg->GetOutputItemSet()));
470 : }
471 : }
472 :
473 0 : delete( pDlg );
474 0 : }
475 : }
476 0 : break;
477 : case SID_TABLE_VERT_NONE:
478 : case SID_TABLE_VERT_CENTER:
479 : case SID_TABLE_VERT_BOTTOM:
480 : {
481 0 : sal_uInt16 nSId = rReq.GetSlot();
482 0 : if (pSdrView->AreObjectsMarked())
483 : {
484 0 : SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
485 0 : if (nSId == SID_TABLE_VERT_CENTER)
486 0 : eTVA = SDRTEXTVERTADJUST_CENTER;
487 0 : else if (nSId == SID_TABLE_VERT_BOTTOM)
488 0 : eTVA = SDRTEXTVERTADJUST_BOTTOM;
489 :
490 0 : SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() );
491 0 : pSdrView->GetAttributes( aNewAttr );
492 0 : aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
493 0 : pSdrView->SetAttributes(aNewAttr);
494 0 : rReq.Done();
495 : }
496 :
497 : }
498 0 : break;
499 :
500 : default:
501 : OSL_ENSURE(!this, "unexpected slot-id");
502 0 : return;
503 : }
504 :
505 0 : GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
506 :
507 0 : if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
508 0 : rSh.SetModified();
509 : }
510 :
511 : // Execute undo
512 :
513 0 : void SwDrawTextShell::ExecUndo(SfxRequest &rReq)
514 : {
515 0 : if( IsTextEdit() )
516 : {
517 0 : bool bCallBase = true;
518 0 : const SfxItemSet* pArgs = rReq.GetArgs();
519 0 : if( pArgs )
520 : {
521 0 : sal_uInt16 nId = rReq.GetSlot(), nCnt = 1;
522 : const SfxPoolItem* pItem;
523 0 : switch( nId )
524 : {
525 : case SID_UNDO:
526 : case SID_REDO:
527 0 : if( SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pItem ) &&
528 0 : 1 < (nCnt = ((SfxUInt16Item*)pItem)->GetValue()) )
529 : {
530 : // then we make by ourself.
531 0 : ::svl::IUndoManager* pUndoManager = GetUndoManager();
532 0 : if( pUndoManager )
533 : {
534 0 : if( SID_UNDO == nId )
535 0 : while( nCnt-- )
536 0 : pUndoManager->Undo();
537 : else
538 0 : while( nCnt-- )
539 0 : pUndoManager->Redo();
540 : }
541 0 : bCallBase = false;
542 0 : GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
543 : }
544 0 : break;
545 : }
546 : }
547 0 : if( bCallBase )
548 : {
549 0 : SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
550 0 : pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface());
551 : }
552 : }
553 0 : }
554 :
555 : // State of undo
556 :
557 0 : void SwDrawTextShell::StateUndo(SfxItemSet &rSet)
558 : {
559 0 : if ( !IsTextEdit() )
560 0 : return;
561 :
562 0 : SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
563 0 : SfxWhichIter aIter(rSet);
564 0 : sal_uInt16 nWhich = aIter.FirstWhich();
565 0 : while( nWhich )
566 : {
567 0 : switch ( nWhich )
568 : {
569 : case SID_GETUNDOSTRINGS:
570 : case SID_GETREDOSTRINGS:
571 : {
572 0 : ::svl::IUndoManager* pUndoManager = GetUndoManager();
573 0 : if( pUndoManager )
574 : {
575 : OUString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
576 :
577 : sal_uInt16 nCount;
578 0 : if( SID_GETUNDOSTRINGS == nWhich )
579 : {
580 0 : nCount = pUndoManager->GetUndoActionCount();
581 0 : fnGetComment = &::svl::IUndoManager::GetUndoActionComment;
582 : }
583 : else
584 : {
585 0 : nCount = pUndoManager->GetRedoActionCount();
586 0 : fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
587 : }
588 0 : if( nCount )
589 : {
590 0 : OUString sList;
591 0 : for( sal_uInt16 n = 0; n < nCount; ++n )
592 0 : sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) + "\n";
593 :
594 0 : SfxStringListItem aItem( nWhich );
595 0 : aItem.SetString( sList );
596 0 : rSet.Put( aItem );
597 : }
598 : }
599 : else
600 0 : rSet.DisableItem( nWhich );
601 : }
602 0 : break;
603 :
604 : default:
605 : pSfxViewFrame->GetSlotState( nWhich,
606 0 : pSfxViewFrame->GetInterface(), &rSet );
607 : }
608 :
609 0 : nWhich = aIter.NextWhich();
610 0 : }
611 : }
612 :
613 0 : void SwDrawTextShell::ExecTransliteration( SfxRequest & rReq )
614 : {
615 0 : if (!pSdrView)
616 0 : return;
617 :
618 : using namespace i18n;
619 :
620 0 : sal_uInt32 nMode = 0;
621 :
622 0 : switch( rReq.GetSlot() )
623 : {
624 : case SID_TRANSLITERATE_SENTENCE_CASE:
625 0 : nMode = TransliterationModulesExtra::SENTENCE_CASE;
626 0 : break;
627 : case SID_TRANSLITERATE_TITLE_CASE:
628 0 : nMode = TransliterationModulesExtra::TITLE_CASE;
629 0 : break;
630 : case SID_TRANSLITERATE_TOGGLE_CASE:
631 0 : nMode = TransliterationModulesExtra::TOGGLE_CASE;
632 0 : break;
633 : case SID_TRANSLITERATE_UPPER:
634 0 : nMode = TransliterationModules_LOWERCASE_UPPERCASE;
635 0 : break;
636 : case SID_TRANSLITERATE_LOWER:
637 0 : nMode = TransliterationModules_UPPERCASE_LOWERCASE;
638 0 : break;
639 :
640 : case SID_TRANSLITERATE_HALFWIDTH:
641 0 : nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
642 0 : break;
643 : case SID_TRANSLITERATE_FULLWIDTH:
644 0 : nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
645 0 : break;
646 :
647 : case SID_TRANSLITERATE_HIRAGANA:
648 0 : nMode = TransliterationModules_KATAKANA_HIRAGANA;
649 0 : break;
650 : case SID_TRANSLITERATE_KATAGANA:
651 0 : nMode = TransliterationModules_HIRAGANA_KATAKANA;
652 0 : break;
653 :
654 : default:
655 : OSL_ENSURE(!this, "wrong dispatcher");
656 : }
657 :
658 0 : if( nMode )
659 : {
660 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
661 :
662 0 : if (!pOLV)
663 0 : return;
664 :
665 0 : pOLV->TransliterateText( nMode );
666 : }
667 : }
668 :
669 0 : void SwDrawTextShell::ExecRotateTransliteration( SfxRequest & rReq )
670 : {
671 0 : if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
672 : {
673 0 : if (!pSdrView)
674 0 : return;
675 :
676 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
677 :
678 0 : if (!pOLV)
679 0 : return;
680 :
681 0 : pOLV->TransliterateText( m_aRotateCase.getNextMode() );
682 : }
683 : }
684 :
685 : // Insert special character (see SDraw: FUBULLET.CXX)
686 :
687 0 : void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
688 : {
689 0 : OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
690 0 : if(!pOLV)
691 0 : return;
692 0 : const SfxItemSet *pArgs = rReq.GetArgs();
693 0 : const SfxPoolItem* pItem = 0;
694 0 : if( pArgs )
695 0 : pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
696 :
697 0 : String sSym;
698 0 : String sFontName;
699 0 : if ( pItem )
700 : {
701 0 : sSym = ((const SfxStringItem*)pItem)->GetValue();
702 0 : const SfxPoolItem* pFtItem = NULL;
703 0 : pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
704 0 : const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
705 0 : if ( pFontItem )
706 0 : sFontName = pFontItem->GetValue();
707 : }
708 :
709 0 : SfxItemSet aSet(pOLV->GetAttribs());
710 0 : sal_uInt16 nScript = pOLV->GetSelectedScriptType();
711 0 : SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
712 : {
713 0 : SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
714 0 : aSetItem.GetItemSet().Put( aSet, sal_False );
715 0 : const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
716 0 : if( pI )
717 0 : aSetDlgFont = *(SvxFontItem*)pI;
718 : else
719 : aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
720 : SID_ATTR_CHAR_FONT,
721 0 : GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
722 0 : if (!sFontName.Len())
723 0 : sFontName = aSetDlgFont.GetFamilyName();
724 : }
725 :
726 0 : Font aFont(sFontName, Size(1,1));
727 0 : if(!sSym.Len())
728 : {
729 0 : SfxAllItemSet aAllSet( GetPool() );
730 0 : aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
731 :
732 0 : SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
733 0 : String sSymbolFont = aOpt.GetSymbolFont();
734 0 : if( sSymbolFont.Len() )
735 0 : aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
736 : else
737 0 : aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) );
738 :
739 : // If character is selected, it can be shown
740 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
741 : SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
742 0 : rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
743 0 : sal_uInt16 nResult = pDlg->Execute();
744 0 : if( nResult == RET_OK )
745 : {
746 0 : SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False );
747 0 : SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
748 0 : if ( pFontItem )
749 : {
750 0 : aFont.SetName( pFontItem->GetFamilyName() );
751 0 : aFont.SetStyleName( pFontItem->GetStyleName() );
752 0 : aFont.SetCharSet( pFontItem->GetCharSet() );
753 0 : aFont.SetPitch( pFontItem->GetPitch() );
754 : }
755 :
756 0 : if ( pCItem )
757 : {
758 0 : sSym = pCItem->GetValue();
759 0 : aOpt.SetSymbolFont(aFont.GetName());
760 0 : SW_MOD()->ApplyUsrPref(aOpt, &rView);
761 : }
762 : }
763 :
764 0 : delete( pDlg );
765 : }
766 :
767 0 : if( sSym.Len() )
768 : {
769 : // do not flicker
770 0 : pOLV->HideCursor();
771 0 : SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
772 0 : pOutliner->SetUpdateMode(sal_False);
773 :
774 0 : SfxItemSet aOldSet( pOLV->GetAttribs() );
775 0 : SfxItemSet aFontSet( *aOldSet.GetPool(),
776 : EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
777 : EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
778 : EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
779 0 : 0 );
780 0 : aFontSet.Set( aOldSet );
781 :
782 : // Insert string
783 0 : pOLV->InsertText( sSym );
784 :
785 : // assign attributes (Set font)
786 0 : SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() );
787 0 : SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(),
788 0 : aFont.GetStyleName(), aFont.GetPitch(),
789 0 : aFont.GetCharSet(),
790 0 : EE_CHAR_FONTINFO );
791 0 : nScript = g_pBreakIt->GetAllScriptsOfText( sSym );
792 0 : if( SCRIPTTYPE_LATIN & nScript )
793 0 : aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO );
794 0 : if( SCRIPTTYPE_ASIAN & nScript )
795 0 : aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
796 0 : if( SCRIPTTYPE_COMPLEX & nScript )
797 0 : aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
798 0 : pOLV->SetAttribs(aFontAttribSet);
799 :
800 : // Remove selection
801 0 : ESelection aSel(pOLV->GetSelection());
802 0 : aSel.nStartPara = aSel.nEndPara;
803 0 : aSel.nStartPos = aSel.nEndPos;
804 0 : pOLV->SetSelection(aSel);
805 :
806 : // Restore old font
807 0 : pOLV->SetAttribs( aFontSet );
808 :
809 : // From now on show again
810 0 : pOutliner->SetUpdateMode(sal_True);
811 0 : pOLV->ShowCursor();
812 :
813 0 : rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) );
814 0 : if(aFont.GetName().Len())
815 0 : rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) );
816 0 : rReq.Done();
817 0 : }
818 : }
819 :
820 0 : ::svl::IUndoManager* SwDrawTextShell::GetUndoManager()
821 : {
822 0 : SwWrtShell &rSh = GetShell();
823 0 : pSdrView = rSh.GetDrawView();
824 0 : SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
825 0 : return &pOutliner->GetUndoManager();
826 : }
827 :
828 0 : void SwDrawTextShell::GetStatePropPanelAttr(SfxItemSet &rSet)
829 : {
830 0 : SfxWhichIter aIter( rSet );
831 0 : sal_uInt16 nWhich = aIter.FirstWhich();
832 :
833 0 : SwWrtShell &rSh = GetShell();
834 0 : pSdrView = rSh.GetDrawView();
835 :
836 0 : SfxItemSet aAttrs( pSdrView->GetModel()->GetItemPool() );
837 0 : pSdrView->GetAttributes( aAttrs );
838 :
839 0 : while ( nWhich )
840 : {
841 0 : sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
842 0 : ? GetPool().GetSlotId(nWhich)
843 0 : : nWhich;
844 0 : switch ( nSlotId )
845 : {
846 : case SID_TABLE_VERT_NONE:
847 : case SID_TABLE_VERT_CENTER:
848 : case SID_TABLE_VERT_BOTTOM:
849 0 : sal_Bool bContour = sal_False;
850 0 : SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
851 0 : if( eConState != SFX_ITEM_DONTCARE )
852 : {
853 0 : bContour = ( ( const SdrTextContourFrameItem& )aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
854 : }
855 0 : if (bContour) break;
856 :
857 0 : SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
858 : //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
859 :
860 : //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
861 0 : if(SFX_ITEM_DONTCARE != eVState)
862 : {
863 0 : SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
864 0 : sal_Bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) ||
865 0 : (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) ||
866 0 : (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM);
867 0 : rSet.Put(SfxBoolItem(nSlotId, bSet));
868 : }
869 : else
870 : {
871 0 : rSet.Put(SfxBoolItem(nSlotId, sal_False));
872 : }
873 0 : break;
874 : }
875 0 : nWhich = aIter.NextWhich();
876 0 : }
877 99 : }
878 :
879 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|