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