1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drwtxtsh.cxx,v $
10 * $Revision: 1.42.190.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <hintids.hxx>
34 #include <i18npool/lang.h>
35 #include <svtools/slstitm.hxx>
36 #include <svtools/cjkoptions.hxx>
37 #include <svx/fontitem.hxx>
38 #include <svx/langitem.hxx>
39 #include <svx/svdview.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <sfx2/objface.hxx>
43 #include <svx/svdotext.hxx>
44 #include <svx/xftsfit.hxx>
45 #include <svx/editeng.hxx>
46 #include <svx/editview.hxx>
47 #include <svx/eeitem.hxx>
48 #include <svx/scripttypeitem.hxx>
49 #include <sfx2/bindings.hxx>
50 #include <svx/fontwork.hxx>
51 #include <sfx2/request.hxx>
52 #include <svtools/whiter.hxx>
53 #include <svx/outliner.hxx>
54 #include <svx/editstat.hxx>
55 #include <svx/svdoutl.hxx>
57 #include <com/sun/star/i18n/TransliterationModules.hpp>
58 #include <com/sun/star/i18n/TextConversionOption.hpp>
59 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
60 #include <com/sun/star/lang/XInitialization.hpp>
61 #include <swtypes.hxx>
64 #include <viewopt.hxx>
65 #include <initui.hxx> // fuer SpellPointer
66 #include <drwtxtsh.hxx>
68 #include <breakit.hxx>
77 #include <globals.hrc>
83 #define SwDrawTextShell
84 #include <sfx2/msg.hxx>
85 #include <swslots.hxx>
91 #include <swmodule.hxx>
93 #include <svx/xtable.hxx>
94 #include <svx/svxdlg.hxx>
95 #include <svx/dialogs.hrc>
97 #include <svx/svxdlg.hxx>
98 #include <svx/dialogs.hrc>
100 #include <cppuhelper/bootstrap.hxx>
102 #include "swabstdlg.hxx" //CHINA001
105 using namespace ::com::sun::star
;
106 using namespace ::com::sun::star::uno
;
107 using namespace ::com::sun::star::beans
;
108 using namespace ::com::sun::star::i18n
;
112 SFX_IMPL_INTERFACE(SwDrawTextShell
, SfxShell
, SW_RES(STR_SHELLNAME_DRAW_TEXT
))
114 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRWTXT_POPUPMENU
));
115 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_DRAW_TEXT_TOOLBOX
));
116 SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
119 TYPEINIT1(SwDrawTextShell
,SfxShell
)
121 /*--------------------------------------------------------------------
123 --------------------------------------------------------------------*/
127 void SwDrawTextShell::Init()
129 SwWrtShell
&rSh
= GetShell();
130 pSdrView
= rSh
.GetDrawView();
131 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
132 //#97471# mouse click _and_ key input at the same time
135 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
136 ULONG nCtrl
= pOutliner
->GetControlWord();
137 nCtrl
|= EE_CNTRL_AUTOCORRECT
;
139 SetUndoManager(&pOutliner
->GetUndoManager());
141 // jetzt versuchen wir mal ein AutoSpell
143 const SwViewOption
* pVOpt
= rSh
.GetViewOptions();
144 if(pVOpt
->IsOnlineSpell())
146 nCtrl
|= EE_CNTRL_ONLINESPELLING
|EE_CNTRL_ALLOWBIGOBJS
;
149 nCtrl
&= ~(EE_CNTRL_ONLINESPELLING
);
151 pOutliner
->SetControlWord(nCtrl
);
155 /*--------------------------------------------------------------------
157 --------------------------------------------------------------------*/
160 SwDrawTextShell::SwDrawTextShell(SwView
&rV
) :
164 SwWrtShell
&rSh
= GetShell();
165 SetPool(rSh
.GetAttrPool().GetSecondaryPool());
170 SetName(String::CreateFromAscii("ObjectText"));
171 SetHelpId(SW_DRWTXTSHELL
);
174 /*--------------------------------------------------------------------
176 --------------------------------------------------------------------*/
180 __EXPORT
SwDrawTextShell::~SwDrawTextShell()
182 if ( GetView().GetCurShell() == this )
183 rView
.ResetSubShell();
185 //MA 13. Nov. 96: Das kommt durchaus vor #33141#:
186 //(doppel-)Klick von einem Texteditmode in ein anderes Objekt, zwischendurch
187 //wird eine andere (Draw-)Shell gepusht, die alte aber noch nicht deletet.
188 //Dann wird vor dem Flush wieder ein DrawTextShell gepusht und der Mode ist
189 //eingeschaltet. In diesem Moment wird der Dispatcher geflusht und die alte
190 //DrawTextShell zerstoert.
191 // ASSERT( !pSdrView->IsTextEdit(), "TextEdit in DTor DrwTxtSh?" );
192 // if (pSdrView->IsTextEdit())
193 // GetShell().EndTextEdit(); // Danebengeklickt, Ende mit Edit
195 // GetShell().Edit();
198 SwWrtShell
& SwDrawTextShell::GetShell()
200 return rView
.GetWrtShell();
204 /*--------------------------------------------------------------------
205 Beschreibung: Slots mit dieser Statusmethode disablen
206 --------------------------------------------------------------------*/
208 void SwDrawTextShell::StateDisableItems( SfxItemSet
&rSet
)
210 SfxWhichIter
aIter(rSet
);
211 USHORT nWhich
= aIter
.FirstWhich();
215 rSet
.DisableItem( nWhich
);
216 nWhich
= aIter
.NextWhich();
221 /*************************************************************************
225 \************************************************************************/
229 void SwDrawTextShell::SetAttrToMarked(const SfxItemSet
& rAttr
)
232 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
233 Rectangle aOutRect
= pOLV
->GetOutputArea();
235 if (aNullRect
!= aOutRect
)
237 GetShell().GetDrawView()->SetAttributes(rAttr
);
242 /*--------------------------------------------------------------------
244 --------------------------------------------------------------------*/
248 BOOL
SwDrawTextShell::IsTextEdit()
250 return pSdrView
->IsTextEdit();
253 /*--------------------------------------------------------------------
255 --------------------------------------------------------------------*/
259 void SwDrawTextShell::ExecFontWork(SfxRequest
& rReq
)
261 SwWrtShell
&rSh
= GetShell();
262 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &rSh
.GetView()));
263 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)) );
264 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
265 if ( rReq
.GetArgs() )
267 pVFrame
->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
268 ((const SfxBoolItem
&) (rReq
.GetArgs()->
269 Get(SID_FONTWORK
))).GetValue());
272 pVFrame
->ToggleChildWindow(SvxFontWorkChildWindow::GetChildWindowId());
274 pVFrame
->GetBindings().Invalidate(SID_FONTWORK
);
277 /*--------------------------------------------------------------------
279 --------------------------------------------------------------------*/
283 void SwDrawTextShell::StateFontWork(SfxItemSet
& rSet
)
285 const USHORT nId
= SvxFontWorkChildWindow::GetChildWindowId();
286 rSet
.Put(SfxBoolItem(SID_FONTWORK
, GetView().GetViewFrame()->HasChildWindow(nId
)));
289 /*************************************************************************
291 |* SfxRequests fuer FontWork bearbeiten
293 \************************************************************************/
297 void SwDrawTextShell::ExecFormText(SfxRequest
& rReq
)
299 SwWrtShell
&rSh
= GetShell();
300 SdrView
* pDrView
= rSh
.GetDrawView();
302 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
304 if ( rMarkList
.GetMarkCount() == 1 && rReq
.GetArgs() )
306 const SfxItemSet
& rSet
= *rReq
.GetArgs();
307 const SfxPoolItem
* pItem
;
309 //ask for the ViewFrame here - "this" may not be valid any longer!
310 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
311 if ( pDrView
->IsTextEdit() )
313 //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and
314 // 'this' is not valid anymore
315 SwView
& rTempView
= GetView();
316 pDrView
->SdrEndTextEdit(sal_True
);
317 //this removes the current shell from the dispatcher stack!!
318 rTempView
.AttrChangedNotify(&rSh
);
321 if ( rSet
.GetItemState(XATTR_FORMTXTSTDFORM
, TRUE
, &pItem
) ==
323 ((const XFormTextStdFormItem
*) pItem
)->GetValue() != XFTFORM_NONE
)
326 const USHORT nId
= SvxFontWorkChildWindow::GetChildWindowId();
327 SvxFontWorkDialog
* pDlg
= (SvxFontWorkDialog
*)(
328 pVFrame
->GetChildWindow(nId
)->GetWindow());
330 pDlg
->CreateStdFormObj(*pDrView
, *pDrView
->GetSdrPageView(),
331 rSet
, *rMarkList
.GetMark(0)->GetMarkedSdrObj(),
332 ((const XFormTextStdFormItem
*) pItem
)->
336 pDrView
->SetAttributes(rSet
);
341 /*************************************************************************
343 |* Statuswerte fuer FontWork zurueckgeben
345 \************************************************************************/
349 void SwDrawTextShell::GetFormTextState(SfxItemSet
& rSet
)
351 SwWrtShell
&rSh
= GetShell();
352 SdrView
* pDrView
= rSh
.GetDrawView();
353 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
354 const SdrObject
* pObj
= NULL
;
355 SvxFontWorkDialog
* pDlg
= NULL
;
357 const USHORT nId
= SvxFontWorkChildWindow::GetChildWindowId();
359 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
360 if ( pVFrame
->HasChildWindow(nId
) )
361 pDlg
= (SvxFontWorkDialog
*)(pVFrame
->GetChildWindow(nId
)->GetWindow());
363 if ( rMarkList
.GetMarkCount() == 1 )
364 pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
366 if ( pObj
== NULL
|| !pObj
->ISA(SdrTextObj
) ||
367 !((SdrTextObj
*) pObj
)->HasText() )
370 static const USHORT nXAttr
[ XATTR_ANZ
] =
371 { XATTR_FORMTXTSTYLE
, XATTR_FORMTXTADJUST
, XATTR_FORMTXTDISTANCE
,
372 XATTR_FORMTXTSTART
, XATTR_FORMTXTMIRROR
, XATTR_FORMTXTSTDFORM
,
373 XATTR_FORMTXTHIDEFORM
, XATTR_FORMTXTOUTLINE
, XATTR_FORMTXTSHADOW
,
374 XATTR_FORMTXTSHDWCOLOR
, XATTR_FORMTXTSHDWXVAL
, XATTR_FORMTXTSHDWYVAL
376 for( USHORT i
= 0; i
< XATTR_ANZ
; )
377 rSet
.DisableItem( nXAttr
[ i
++ ] );
382 pDlg
->SetColorTable(XColorTable::GetStdColorTable());
384 pDrView
->GetAttributes( rSet
);
388 /*--------------------------------------------------------------------
390 --------------------------------------------------------------------*/
394 void SwDrawTextShell::ExecDrawLingu(SfxRequest
&rReq
)
396 SwWrtShell
&rSh
= GetShell();
397 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
398 if( rSh
.GetDrawView()->GetMarkedObjectList().GetMarkCount() )
400 switch(rReq
.GetSlot())
402 case FN_THESAURUS_DLG
:
403 pOLV
->StartThesaurus();
406 case SID_HANGUL_HANJA_CONVERSION
:
407 pOLV
->StartTextConversion( LANGUAGE_KOREAN
, LANGUAGE_KOREAN
, NULL
,
408 i18n::TextConversionOption::CHARACTER_BY_CHARACTER
, sal_True
, sal_False
);
411 case SID_CHINESE_CONVERSION
:
413 //open ChineseTranslationDialog
414 Reference
< XComponentContext
> xContext(
415 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
418 Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
421 Reference
< ui::dialogs::XExecutableDialog
> xDialog(
422 xMCF
->createInstanceWithContext(
423 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
424 , xContext
), UNO_QUERY
);
425 Reference
< lang::XInitialization
> xInit( xDialog
, UNO_QUERY
);
429 Reference
< awt::XWindow
> xDialogParentWindow(0);
430 Sequence
<Any
> aSeq(1);
431 Any
* pArray
= aSeq
.getArray();
432 PropertyValue aParam
;
433 aParam
.Name
= rtl::OUString::createFromAscii("ParentWindow");
434 aParam
.Value
<<= makeAny(xDialogParentWindow
);
435 pArray
[0] <<= makeAny(aParam
);
436 xInit
->initialize( aSeq
);
439 sal_Int16 nDialogRet
= xDialog
->execute();
440 if( RET_OK
== nDialogRet
)
442 //get some parameters from the dialog
443 sal_Bool bToSimplified
= sal_True
;
444 sal_Bool bUseVariants
= sal_True
;
445 sal_Bool bCommonTerms
= sal_True
;
446 Reference
< beans::XPropertySet
> xProp( xDialog
, UNO_QUERY
);
451 xProp
->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified
;
452 xProp
->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants
;
453 xProp
->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms
;
460 //execute translation
461 sal_Int16 nSourceLang
= bToSimplified
? LANGUAGE_CHINESE_TRADITIONAL
: LANGUAGE_CHINESE_SIMPLIFIED
;
462 sal_Int16 nTargetLang
= bToSimplified
? LANGUAGE_CHINESE_SIMPLIFIED
: LANGUAGE_CHINESE_TRADITIONAL
;
463 sal_Int32 nOptions
= bUseVariants
? i18n::TextConversionOption::USE_CHARACTER_VARIANTS
: 0;
465 nOptions
= nOptions
| i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
467 Font aTargetFont
= pOLV
->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT
,
468 nTargetLang
, DEFAULTFONT_FLAGS_ONLYONE
);
470 pOLV
->StartTextConversion( nSourceLang
, nTargetLang
, &aTargetFont
, nOptions
, sal_False
, sal_False
);
473 Reference
< lang::XComponent
> xComponent( xDialog
, UNO_QUERY
);
474 if( xComponent
.is() )
475 xComponent
->dispose();
482 ASSERT(!this, "unexpected slot-id");
487 /*--------------------------------------------------------------------
489 --------------------------------------------------------------------*/
490 void SwDrawTextShell::ExecDraw(SfxRequest
&rReq
)
492 SwWrtShell
&rSh
= GetShell();
493 pSdrView
= rSh
.GetDrawView();
494 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
496 switch (rReq
.GetSlot())
498 case FN_INSERT_SOFT_HYPHEN
:
499 case FN_INSERT_HARDHYPHEN
:
500 case FN_INSERT_HARD_SPACE
:
501 case SID_INSERT_RLM
:
502 case SID_INSERT_LRM
:
503 case SID_INSERT_ZWNBSP
:
504 case SID_INSERT_ZWSP
:
506 sal_Unicode cIns
= 0;
507 switch(rReq
.GetSlot())
509 case FN_INSERT_SOFT_HYPHEN
: cIns
= CHAR_SOFTHYPHEN
; break;
510 case FN_INSERT_HARDHYPHEN
: cIns
= CHAR_HARDHYPHEN
; break;
511 case FN_INSERT_HARD_SPACE
: cIns
= CHAR_HARDBLANK
; break;
512 case SID_INSERT_RLM
: cIns
= CHAR_RLM
; break;
513 case SID_INSERT_LRM
: cIns
= CHAR_LRM
; break;
514 case SID_INSERT_ZWSP
: cIns
= CHAR_ZWSP
; break;
515 case SID_INSERT_ZWNBSP
: cIns
= CHAR_ZWNBSP
; break;
517 pOLV
->InsertText( String(cIns
), TRUE
);
522 { // Sonderzeichen einfuegen
526 case FN_INSERT_STRING
:
528 const SfxItemSet
*pNewAttrs
= rReq
.GetArgs();
529 sal_uInt16 nSlot
= rReq
.GetSlot();
530 const SfxPoolItem
* pItem
= 0;
533 pNewAttrs
->GetItemState(nSlot
, FALSE
, &pItem
);
534 pOLV
->InsertText(((const SfxStringItem
*)pItem
)->GetValue());
541 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
544 ULONG nParaCount
= pOutliner
->GetParagraphCount();
546 pOLV
->SelectRange(0L, USHORT(nParaCount
) );
551 case FN_FORMAT_RESET
: // delete hard text attributes
553 pOLV
->RemoveAttribsKeepLanguages( true );
554 pOLV
->GetEditView().GetEditEngine()->RemoveFields(TRUE
);
560 if (pSdrView
->IsTextEdit())
564 SwView
& rTempView
= rSh
.GetView();
565 rTempView
.ExitDraw();
567 rTempView
.AttrChangedNotify(&rSh
);
571 case FN_DRAWTEXT_ATTR_DLG
:
573 SfxItemSet
aNewAttr( pSdrView
->GetModel()->GetItemPool() );
574 pSdrView
->GetAttributes( aNewAttr
);
575 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
578 SfxAbstractTabDialog
*pDlg
= pFact
->CreateTextTabDialog(
579 &(GetView().GetViewFrame()->GetWindow()),
580 &aNewAttr
, RID_SVXDLG_TEXT
, pSdrView
);
581 USHORT nResult
= pDlg
->Execute();
583 if (nResult
== RET_OK
)
585 if (pSdrView
->AreObjectsMarked())
587 pSdrView
->SetAttributes(*pDlg
->GetOutputItemSet());
588 rReq
.Done(*(pDlg
->GetOutputItemSet()));
598 ASSERT(!this, "unexpected slot-id");
602 GetView().GetViewFrame()->GetBindings().InvalidateAll(FALSE
);
604 if (IsTextEdit() && pOLV
->GetOutliner()->IsModified())
608 /*--------------------------------------------------------------------
609 Beschreibung: Undo ausfuehren
610 --------------------------------------------------------------------*/
614 void SwDrawTextShell::ExecUndo(SfxRequest
&rReq
)
618 BOOL bCallBase
= TRUE
;
619 const SfxItemSet
* pArgs
= rReq
.GetArgs();
622 USHORT nId
= rReq
.GetSlot(), nCnt
= 1;
623 const SfxPoolItem
* pItem
;
628 if( SFX_ITEM_SET
== pArgs
->GetItemState( nId
, FALSE
, &pItem
) &&
629 1 < (nCnt
= ((SfxUInt16Item
*)pItem
)->GetValue()) )
631 // then we make by ourself.
632 SfxUndoManager
* pUndoManager
= GetUndoManager();
635 if( SID_UNDO
== nId
)
637 pUndoManager
->Undo(0);
640 pUndoManager
->Redo(0);
649 SfxViewFrame
*pSfxViewFrame
= GetView().GetViewFrame();
650 pSfxViewFrame
->ExecuteSlot(rReq
, pSfxViewFrame
->GetInterface());
655 /*--------------------------------------------------------------------
656 Beschreibung: Zustand Undo
657 --------------------------------------------------------------------*/
661 void SwDrawTextShell::StateUndo(SfxItemSet
&rSet
)
666 SfxViewFrame
*pSfxViewFrame
= GetView().GetViewFrame();
667 SfxWhichIter
aIter(rSet
);
668 USHORT nWhich
= aIter
.FirstWhich();
673 case SID_GETUNDOSTRINGS
:
674 case SID_GETREDOSTRINGS
:
676 SfxUndoManager
* pUndoManager
= GetUndoManager();
679 UniString (SfxUndoManager:: *fnGetComment
)( USHORT
) const;
682 if( SID_GETUNDOSTRINGS
== nWhich
)
684 nCount
= pUndoManager
->GetUndoActionCount();
685 fnGetComment
= &SfxUndoManager::GetUndoActionComment
;
689 nCount
= pUndoManager
->GetRedoActionCount();
690 fnGetComment
= &SfxUndoManager::GetRedoActionComment
;
695 for( sal_uInt16 n
= 0; n
< nCount
; ++n
)
696 ( sList
+= (pUndoManager
->*fnGetComment
)( n
) )
699 SfxStringListItem
aItem( nWhich
);
700 aItem
.SetString( sList
);
705 rSet
.DisableItem( nWhich
);
710 pSfxViewFrame
->GetSlotState( nWhich
,
711 pSfxViewFrame
->GetInterface(), &rSet
);
714 nWhich
= aIter
.NextWhich();
718 void SwDrawTextShell::ExecTransliteration( SfxRequest
& rReq
)
720 using namespace i18n
;
722 sal_uInt32 nMode
= 0;
724 switch( rReq
.GetSlot() )
726 case SID_TRANSLITERATE_UPPER
:
727 nMode
= TransliterationModules_LOWERCASE_UPPERCASE
;
729 case SID_TRANSLITERATE_LOWER
:
730 nMode
= TransliterationModules_UPPERCASE_LOWERCASE
;
733 case SID_TRANSLITERATE_HALFWIDTH
:
734 nMode
= TransliterationModules_FULLWIDTH_HALFWIDTH
;
736 case SID_TRANSLITERATE_FULLWIDTH
:
737 nMode
= TransliterationModules_HALFWIDTH_FULLWIDTH
;
740 case SID_TRANSLITERATE_HIRAGANA
:
741 nMode
= TransliterationModules_KATAKANA_HIRAGANA
;
743 case SID_TRANSLITERATE_KATAGANA
:
744 nMode
= TransliterationModules_HIRAGANA_KATAKANA
;
748 ASSERT(!this, "falscher Dispatcher");
753 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
754 pOLV
->TransliterateText( nMode
);
759 /*--------------------------------------------------------------------
760 Beschreibung: Sonderzeichen einfuegen (siehe SDraw: FUBULLET.CXX)
761 --------------------------------------------------------------------*/
763 void SwDrawTextShell::InsertSymbol(SfxRequest
& rReq
)
765 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
768 const SfxItemSet
*pArgs
= rReq
.GetArgs();
769 const SfxPoolItem
* pItem
= 0;
771 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), FALSE
, &pItem
);
777 sSym
= ((const SfxStringItem
*)pItem
)->GetValue();
778 const SfxPoolItem
* pFtItem
= NULL
;
779 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), FALSE
, &pFtItem
);
780 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
782 sFontName
= pFontItem
->GetValue();
785 SfxItemSet
aSet(pOLV
->GetAttribs());
786 USHORT nScript
= pOLV
->GetSelectedScriptType();
787 SvxFontItem
aSetDlgFont( RES_CHRATR_FONT
);
789 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONT
, *aSet
.GetPool() );
790 aSetItem
.GetItemSet().Put( aSet
, FALSE
);
791 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScript
);
793 aSetDlgFont
= *(SvxFontItem
*)pI
;
795 aSetDlgFont
= (SvxFontItem
&)aSet
.Get( GetWhichOfScript(
797 GetI18NScriptTypeOfLanguage( (USHORT
)GetAppLanguage() ) ));
798 if (!sFontName
.Len())
799 sFontName
= aSetDlgFont
.GetFamilyName();
802 Font
aFont(sFontName
, Size(1,1));
805 SfxAllItemSet
aAllSet( GetPool() );
806 aAllSet
.Put( SfxBoolItem( FN_PARAM_1
, FALSE
) );
808 SwViewOption
aOpt(*rView
.GetWrtShell().GetViewOptions());
809 String sSymbolFont
= aOpt
.GetSymbolFont();
810 if( sSymbolFont
.Len() )
811 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, sSymbolFont
) );
813 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, aSetDlgFont
.GetFamilyName() ) );
815 // Wenn Zeichen selektiert ist kann es angezeigt werden
816 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
817 SfxAbstractDialog
* pDlg
= pFact
->CreateSfxDialog( rView
.GetWindow(), aAllSet
,
818 rView
.GetViewFrame()->GetFrame()->GetFrameInterface(), RID_SVXDLG_CHARMAP
);
819 USHORT nResult
= pDlg
->Execute();
820 if( nResult
== RET_OK
)
822 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pCItem
, SfxStringItem
, SID_CHARMAP
, FALSE
);
823 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pFontItem
, SvxFontItem
, SID_ATTR_CHAR_FONT
, FALSE
);
826 aFont
.SetName( pFontItem
->GetFamilyName() );
827 aFont
.SetStyleName( pFontItem
->GetStyleName() );
828 aFont
.SetCharSet( pFontItem
->GetCharSet() );
829 aFont
.SetPitch( pFontItem
->GetPitch() );
834 sSym
= pCItem
->GetValue();
835 aOpt
.SetSymbolFont(aFont
.GetName());
836 SW_MOD()->ApplyUsrPref(aOpt
, &rView
);
847 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
848 pOutliner
->SetUpdateMode(FALSE
);
850 SfxItemSet
aOldSet( pOLV
->GetAttribs() );
851 SfxItemSet
aFontSet( *aOldSet
.GetPool(),
852 EE_CHAR_FONTINFO
, EE_CHAR_FONTINFO
,
853 EE_CHAR_FONTINFO_CJK
, EE_CHAR_FONTINFO_CJK
,
854 EE_CHAR_FONTINFO_CTL
, EE_CHAR_FONTINFO_CTL
,
856 aFontSet
.Set( aOldSet
);
859 pOLV
->InsertText( sSym
, TRUE
);
861 // attributieren (Font setzen)
862 SfxItemSet
aFontAttribSet( *aFontSet
.GetPool(), aFontSet
.GetRanges() );
863 SvxFontItem
aFontItem (aFont
.GetFamily(), aFont
.GetName(),
864 aFont
.GetStyleName(), aFont
.GetPitch(),
867 nScript
= pBreakIt
->GetAllScriptsOfText( sSym
);
868 if( SCRIPTTYPE_LATIN
& nScript
)
869 aFontAttribSet
.Put( aFontItem
, EE_CHAR_FONTINFO
);
870 if( SCRIPTTYPE_ASIAN
& nScript
)
871 aFontAttribSet
.Put( aFontItem
, EE_CHAR_FONTINFO_CJK
);
872 if( SCRIPTTYPE_COMPLEX
& nScript
)
873 aFontAttribSet
.Put( aFontItem
, EE_CHAR_FONTINFO_CTL
);
874 pOLV
->SetAttribs(aFontAttribSet
);
876 // Selektion loeschen
877 ESelection
aSel(pOLV
->GetSelection());
878 aSel
.nStartPara
= aSel
.nEndPara
;
879 aSel
.nStartPos
= aSel
.nEndPos
;
880 pOLV
->SetSelection(aSel
);
882 // Alten Font restaurieren
883 pOLV
->SetAttribs( aFontSet
);
885 // ab jetzt wieder anzeigen
886 pOutliner
->SetUpdateMode(TRUE
);
889 rReq
.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP
), sSym
) );
890 if(aFont
.GetName().Len())
891 rReq
.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR
, aFont
.GetName() ) );
895 /*-- 22.10.2003 14:26:32---------------------------------------------------
897 -----------------------------------------------------------------------*/
898 SfxUndoManager
* SwDrawTextShell::GetUndoManager()
900 SwWrtShell
&rSh
= GetShell();
901 pSdrView
= rSh
.GetDrawView();
902 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
903 pOutliner
= pSdrView
->GetTextEditOutliner();
904 return &pOutliner
->GetUndoManager();