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