xref: /trunk/main/sc/source/ui/drawfunc/drtxtob.cxx (revision 512ec161)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 //-------------------------------------------------------------------------
30 
31 #include <com/sun/star/linguistic2/XThesaurus.hpp>
32 #include <com/sun/star/lang/Locale.hpp>
33 
34 #include "scitems.hxx"
35 
36 #include <editeng/adjitem.hxx>
37 #include <svx/clipfmtitem.hxx>
38 #include <editeng/cntritem.hxx>
39 #include <editeng/crsditem.hxx>
40 #include <editeng/editeng.hxx>
41 #include <editeng/escpitem.hxx>
42 #include <editeng/flditem.hxx>
43 #include <editeng/fontitem.hxx>
44 #include <editeng/frmdiritem.hxx>
45 #include <editeng/lrspitem.hxx>
46 #include <editeng/lspcitem.hxx>
47 #include <editeng/ulspitem.hxx>
48 #include <svx/hlnkitem.hxx>
49 #include <editeng/lspcitem.hxx>
50 #include <svx/svdoutl.hxx>
51 #include <editeng/unolingu.hxx>
52 #include <editeng/outlobj.hxx>
53 #include <editeng/postitem.hxx>
54 #include <editeng/scripttypeitem.hxx>
55 #include <editeng/shdditem.hxx>
56 #include <svl/srchitem.hxx>
57 #include <editeng/udlnitem.hxx>
58 #include <editeng/wghtitem.hxx>
59 #include <editeng/writingmodeitem.hxx>
60 #include <sfx2/app.hxx>
61 #include <sfx2/dispatch.hxx>
62 #include <sfx2/objface.hxx>
63 #include <sfx2/objsh.hxx>
64 #include <sfx2/request.hxx>
65 #include <sfx2/viewfrm.hxx>
66 #include <svtools/cliplistener.hxx>
67 #include <svtools/transfer.hxx>
68 #include <svl/whiter.hxx>
69 #include <svl/languageoptions.hxx>
70 #include <vcl/msgbox.hxx>
71 
72 #include <svx/svxdlg.hxx>
73 #include <svx/dialogs.hrc>
74 #include <sfx2/sidebar/EnumContext.hxx>
75 
76 #include "sc.hrc"
77 #include "globstr.hrc"
78 #include "scmod.hxx"
79 #include "drtxtob.hxx"
80 #include "fudraw.hxx"
81 #include "viewdata.hxx"
82 #include "document.hxx"
83 #include "drawview.hxx"
84 #include "viewutil.hxx"
85 #include "scresid.hxx"
86 #include "tabvwsh.hxx"
87 
88 #define ScDrawTextObjectBar
89 #include "scslots.hxx"
90 
91 
92 using namespace ::com::sun::star;
93 
94 
95 SFX_IMPL_INTERFACE( ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL) )
96 {
97 	SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
98 								ScResId(RID_TEXT_TOOLBOX) );
99 	SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT) );
100 	SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() );
101 }
102 
103 TYPEINIT1( ScDrawTextObjectBar, SfxShell );
104 
105 
106 
107 // abschalten der nicht erwuenschten Acceleratoren:
108 
109 void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
110 {
111 	SfxWhichIter aIter(rSet);
112 	sal_uInt16 nWhich = aIter.FirstWhich();
113 
114 	while (nWhich)
115 	{
116 		rSet.DisableItem( nWhich );
117 		nWhich = aIter.NextWhich();
118 	}
119 }
120 
121 ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
122 	SfxShell(pData->GetViewShell()),
123 	pViewData(pData),
124 	pClipEvtLstnr(NULL),
125 	bPastePossible(sal_False)
126 {
127 	SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
128 
129 	//	UndoManager wird beim Umschalten in den Edit-Modus umgesetzt...
130     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
131     SetUndoManager( pMgr );
132     if ( !pViewData->GetDocument()->IsUndoEnabled() )
133     {
134         pMgr->SetMaxUndoActionCount( 0 );
135     }
136 
137 	SetHelpId( HID_SCSHELL_DRTXTOB );
138 	SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawText")));
139     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText));
140 }
141 
142 __EXPORT ScDrawTextObjectBar::~ScDrawTextObjectBar()
143 {
144 	if ( pClipEvtLstnr )
145 	{
146 		pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), sal_False );
147 
148         //  #122057# The listener may just now be waiting for the SolarMutex and call the link
149         //  afterwards, in spite of RemoveListener. So the link has to be reset, too.
150         pClipEvtLstnr->ClearCallbackLink();
151 
152 		pClipEvtLstnr->release();
153 	}
154 }
155 
156 //========================================================================
157 //
158 //			Funktionen
159 //
160 //========================================================================
161 
162 void __EXPORT ScDrawTextObjectBar::Execute( SfxRequest &rReq )
163 {
164 	ScDrawView* pView = pViewData->GetScDrawView();
165 	OutlinerView* pOutView = pView->GetTextEditOutlinerView();
166 	Outliner* pOutliner = pView->GetTextEditOutliner();
167 
168 	if (!pOutView || !pOutliner)
169 	{
170 		ExecuteGlobal( rReq );				// auf ganze Objekte
171 		return;
172 	}
173 
174 	const SfxItemSet* pReqArgs = rReq.GetArgs();
175 	sal_uInt16 nSlot = rReq.GetSlot();
176 	switch ( nSlot )
177 	{
178 		case SID_COPY:
179 			pOutView->Copy();
180 			break;
181 
182 		case SID_CUT:
183 			pOutView->Cut();
184 			break;
185 
186 		case SID_PASTE:
187 			pOutView->PasteSpecial();
188 			break;
189 
190 		case SID_CLIPBOARD_FORMAT_ITEMS:
191 			{
192 				sal_uLong nFormat = 0;
193 				const SfxPoolItem* pItem;
194 				if ( pReqArgs &&
195 					 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
196 					 pItem->ISA(SfxUInt32Item) )
197 				{
198 					nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
199 				}
200 
201 				if ( nFormat )
202 				{
203 					if (nFormat == SOT_FORMAT_STRING)
204 						pOutView->Paste();
205 					else
206 						pOutView->PasteSpecial();
207 				}
208 			}
209 			break;
210 
211         case SID_PASTE_SPECIAL:
212 			ExecutePasteContents( rReq );
213 			break;
214 
215 		case SID_SELECTALL:
216 			{
217 				sal_uLong nCount = pOutliner->GetParagraphCount();
218 				ESelection aSel( 0,0,(sal_uInt16)nCount,0 );
219 				pOutView->SetSelection( aSel );
220 			}
221 			break;
222 
223 		case SID_CHARMAP:
224 			{
225 				const SvxFontItem& rItem = (const SvxFontItem&)
226 							pOutView->GetAttribs().Get(EE_CHAR_FONTINFO);
227 
228 				String aString;
229 				SvxFontItem aNewItem( EE_CHAR_FONTINFO );
230 
231 				const SfxItemSet *pArgs = rReq.GetArgs();
232 				const SfxPoolItem* pItem = 0;
233 				if( pArgs )
234 					pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
235 
236 				if ( pItem )
237 				{
238 					aString = ((const SfxStringItem*)pItem)->GetValue();
239 					const SfxPoolItem* pFtItem = NULL;
240 					pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
241 					const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
242 					if ( pFontItem )
243 					{
244 						String aFontName(pFontItem->GetValue());
245 					    Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
246 						aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
247 									aFont.GetStyleName(), aFont.GetPitch(),
248                                     aFont.GetCharSet(), ATTR_FONT  );
249 					}
250 					else
251 						aNewItem = rItem;
252 				}
253 				else
254 					ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
255 
256 				if ( aString.Len() )
257 				{
258 					SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
259 					aSet.Put( aNewItem );
260 					//	SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
261 					pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() );
262 					pOutView->InsertText(aString);
263 				}
264 
265 				Invalidate( SID_ATTR_CHAR_FONT );
266 			}
267 			break;
268 
269 		case SID_HYPERLINK_SETLINK:
270 			if( pReqArgs )
271 			{
272 				const SfxPoolItem* pItem;
273 				if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
274 				{
275 					const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
276 					const String& rName		= pHyper->GetName();
277 					const String& rURL		= pHyper->GetURL();
278 					const String& rTarget	= pHyper->GetTargetFrame();
279 					SvxLinkInsertMode eMode = pHyper->GetInsertMode();
280 
281 					sal_Bool bDone = sal_False;
282 					if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) )
283 					{
284 						const SvxFieldItem*	pFieldItem = pOutView->GetFieldAtSelection();
285 						if (pFieldItem)
286 						{
287 							const SvxFieldData* pField = pFieldItem->GetField();
288 							if ( pField && pField->ISA(SvxURLField) )
289 							{
290 								//	altes Feld selektieren
291 
292 								ESelection aSel = pOutView->GetSelection();
293 								aSel.Adjust();
294 								aSel.nEndPara = aSel.nStartPara;
295 								aSel.nEndPos = aSel.nStartPos + 1;
296 								pOutView->SetSelection( aSel );
297 							}
298 						}
299 
300 						//	neues Feld einfuegen
301 
302 						SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
303 						aURLField.SetTargetFrame( rTarget );
304                         SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
305 						pOutView->InsertField( aURLItem );
306 
307 						//	select new field
308 
309 						ESelection aSel = pOutView->GetSelection();
310 						if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 )
311 						{
312 							//	Cursor is behind the inserted field -> extend selection to the left
313 
314 							--aSel.nStartPos;
315 							pOutView->SetSelection( aSel );
316 						}
317 
318 						bDone = sal_True;
319 					}
320 
321 					if (!bDone)
322 						ExecuteGlobal( rReq );		// normal an der View
323 
324 					//	InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
325 				}
326 			}
327 			break;
328 
329         case SID_OPEN_HYPERLINK:
330             {
331                 if ( pOutView )
332                 {
333                     const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
334                     if ( pFieldItem )
335                     {
336                         const SvxFieldData* pField = pFieldItem->GetField();
337                         if( pField && pField->ISA( SvxURLField ) )
338                         {
339                             const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
340                             ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
341                         }
342                     }
343                 }
344             }
345             break;
346 
347 		case SID_ENABLE_HYPHENATION:
348 		case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
349 		case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
350 #if 0 // DR
351 		    if (IsNoteEdit())
352 		    {
353 		        pView->CaptionTextDirection( rReq.GetSlot());     // process Notes before we end the text edit.
354 		        ExecuteGlobal( rReq );
355 		        pViewData->GetDispatcher().Execute(pViewData->GetView()->GetDrawFuncPtr()->GetSlotID(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
356 		    }
357 		    else
358 #endif
359 		    {
360 		        pView->ScEndTextEdit();	// end text edit before switching direction
361 		        ExecuteGlobal( rReq );
362 		        // restore consistent state between shells and functions:
363 		        pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
364 		    }
365             break;
366 
367 #if 0
368 		// Hyphenation is handled above - text edit is ended
369 		case SID_ENABLE_HYPHENATION:
370 			// force loading of hyphenator (object is skipped in repaint)
371 			((ScDrawLayer*)pView->GetModel())->UseHyphenator();
372 			pOutliner->SetHyphenator( LinguMgr::GetHyphenator() );
373 			ExecuteGlobal( rReq );
374 			break;
375 #endif
376 
377         case SID_THES:
378             {
379                 String aReplaceText;
380                 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False );
381                 if (pItem2)
382                     aReplaceText = pItem2->GetValue();
383                 if (aReplaceText.Len() > 0)
384                     ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
385             }
386             break;
387 
388         case SID_THESAURUS:
389             {
390                 pOutView->StartThesaurus();
391             }
392             break;
393 
394     }
395 }
396 
397 void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
398 {
399 	SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
400 	sal_Bool bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK);
401 	sal_Bool bDisableFontWork = sal_False;
402 
403 	if (IsNoteEdit())
404 	{
405         // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
406         bDisableFontWork = sal_True;
407 	}
408 
409 	if ( bDisableFontWork )
410 		rSet.DisableItem( SID_FONTWORK	);
411 	else
412 		rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
413 
414 	if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SFX_ITEM_UNKNOWN )
415 	{
416 		SvxHyperlinkItem aHLinkItem;
417 		SdrView* pView = pViewData->GetScDrawView();
418 		OutlinerView* pOutView = pView->GetTextEditOutlinerView();
419 		if ( pOutView )
420 		{
421 			sal_Bool bField = sal_False;
422 			const SvxFieldItem*	pFieldItem = pOutView->GetFieldAtSelection();
423 			if (pFieldItem)
424 			{
425 				const SvxFieldData* pField = pFieldItem->GetField();
426 				if ( pField && pField->ISA(SvxURLField) )
427 				{
428 					const SvxURLField* pURLField = (const SvxURLField*) pField;
429 					aHLinkItem.SetName( pURLField->GetRepresentation() );
430 					aHLinkItem.SetURL( pURLField->GetURL() );
431 					aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
432 					bField = sal_True;
433 				}
434 			}
435 			if (!bField)
436 			{
437 				// use selected text as name for urls
438 				String sReturn = pOutView->GetSelected();
439 				sReturn.Erase(255);
440 				sReturn.EraseTrailingChars();
441 				aHLinkItem.SetName(sReturn);
442 			}
443 		}
444 		rSet.Put(aHLinkItem);
445 	}
446 
447     if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SFX_ITEM_UNKNOWN )
448     {
449         SdrView* pView = pViewData->GetScDrawView();
450         OutlinerView* pOutView = pView->GetTextEditOutlinerView();
451         bool bEnable = false;
452         if ( pOutView )
453         {
454             const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
455             if ( pFieldItem )
456             {
457                 const SvxFieldData* pField = pFieldItem->GetField();
458                 bEnable = pField && pField->ISA( SvxURLField );
459             }
460         }
461         if( !bEnable )
462             rSet.DisableItem( SID_OPEN_HYPERLINK );
463     }
464 
465     if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SFX_ITEM_UNKNOWN )
466         ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
467     if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SFX_ITEM_UNKNOWN )
468         ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
469     if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SFX_ITEM_UNKNOWN )
470         ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA );
471     if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SFX_ITEM_UNKNOWN )
472         ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA );
473 
474 	if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN )
475 	{
476 		SdrView* pView = pViewData->GetScDrawView();
477 		SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
478 		pView->GetAttributes( aAttrs );
479 		if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
480 		{
481 			sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
482 			rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
483 		}
484 	}
485 
486     if ( rSet.GetItemState( SID_THES ) != SFX_ITEM_UNKNOWN  ||
487          rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN )
488     {
489         SdrView * pView = pViewData->GetScDrawView();
490         OutlinerView* pOutView = pView->GetTextEditOutlinerView();
491 
492         String          aStatusVal;
493         LanguageType    nLang = LANGUAGE_NONE;
494         bool bIsLookUpWord = false;
495         if ( pOutView )
496         {
497             EditView& rEditView = pOutView->GetEditView();
498             bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
499         }
500         rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
501 
502         // disable thesaurus main menu and context menu entry if there is nothing to look up
503         sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
504         if (!bIsLookUpWord || !bCanDoThesaurus)
505             rSet.DisableItem( SID_THES );
506         if (!bCanDoThesaurus)
507             rSet.DisableItem( SID_THESAURUS );
508     }
509 }
510 
511 IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper )
512 {
513 	if ( pDataHelper )
514 	{
515 		bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
516 
517 		SfxBindings& rBindings = pViewData->GetBindings();
518 		rBindings.Invalidate( SID_PASTE );
519         rBindings.Invalidate( SID_PASTE_SPECIAL );
520 		rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
521 	}
522 	return 0;
523 }
524 
525 void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
526 {
527 	SdrView* pView = pViewData->GetScDrawView();
528 	if ( !pView->GetTextEditOutlinerView() )
529 	{
530 		GetGlobalClipState( rSet );
531 		return;
532 	}
533 
534 	if ( !pClipEvtLstnr )
535 	{
536 		// create listener
537 		pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
538 		pClipEvtLstnr->acquire();
539 		Window* pWin = pViewData->GetActiveWin();
540 		pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
541 
542 		// get initial state
543 		TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
544 		bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
545 	}
546 
547 	SfxWhichIter aIter( rSet );
548 	sal_uInt16 nWhich = aIter.FirstWhich();
549 	while (nWhich)
550 	{
551 		switch (nWhich)
552 		{
553 			case SID_PASTE:
554             case SID_PASTE_SPECIAL:
555 				if( !bPastePossible )
556 					rSet.DisableItem( nWhich );
557 				break;
558 			case SID_CLIPBOARD_FORMAT_ITEMS:
559 				if ( bPastePossible )
560 				{
561 					SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
562 					TransferableDataHelper aDataHelper(
563 							TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
564 
565 					if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
566 						aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
567 					if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
568 						aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
569 
570 					rSet.Put( aFormats );
571 				}
572 				else
573 					rSet.DisableItem( nWhich );
574 				break;
575 		}
576 		nWhich = aIter.NextWhich();
577 	}
578 }
579 
580 //========================================================================
581 //
582 //			Attribute
583 //
584 //========================================================================
585 
586 void __EXPORT ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq )
587 {
588 	//	Unterstreichung
589 
590 	SdrView* pView = pViewData->GetScDrawView();
591 
592 	sal_uInt16 nSlot = rReq.GetSlot();
593 
594 	SfxItemSet aSet( pView->GetDefaultAttr() );
595 
596 	SfxItemSet aViewAttr(pView->GetModel()->GetItemPool());
597 	pView->GetAttributes(aViewAttr);
598 
599 	//	Unterstreichung
600 	FontUnderline eOld = ((const SvxUnderlineItem&) aViewAttr.
601 										Get(EE_CHAR_UNDERLINE)).GetLineStyle();
602 	FontUnderline eNew = eOld;
603 	switch (nSlot)
604 	{
605 		case SID_ULINE_VAL_NONE:
606 			eNew = UNDERLINE_NONE;
607 			break;
608 		case SID_ULINE_VAL_SINGLE:
609 			eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
610 			break;
611 		case SID_ULINE_VAL_DOUBLE:
612 			eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
613 			break;
614 		case SID_ULINE_VAL_DOTTED:
615 			eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
616 			break;
617 		default:
618 			break;
619 	}
620 	aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
621 
622 	pView->SetAttributes( aSet );
623 	rReq.Done();
624 	pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
625 }
626 
627 void lcl_RemoveFields( OutlinerView& rOutView )
628 {
629 	//!	Outliner should have RemoveFields with a selection
630 
631 	Outliner* pOutliner = rOutView.GetOutliner();
632 	if (!pOutliner) return;
633 
634 	ESelection aOldSel = rOutView.GetSelection();
635 	ESelection aSel = aOldSel;
636 	aSel.Adjust();
637 	xub_StrLen nNewEnd = aSel.nEndPos;
638 
639 	sal_Bool bUpdate = pOutliner->GetUpdateMode();
640 	sal_Bool bChanged = sal_False;
641 
642 	//!	GetPortions and GetAttribs should be const!
643 	EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
644 
645 	sal_uLong nParCount = pOutliner->GetParagraphCount();
646 	for (sal_uLong nPar=0; nPar<nParCount; nPar++)
647 		if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
648 		{
649 			SvUShorts aPortions;
650 			rEditEng.GetPortions( (sal_uInt16)nPar, aPortions );
651 			//!	GetPortions should use xub_StrLen instead of sal_uInt16
652 
653 			for ( sal_uInt16 nPos = aPortions.Count(); nPos; )
654 			{
655 				--nPos;
656 				sal_uInt16 nEnd = aPortions.GetObject( nPos );
657 				sal_uInt16 nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0;
658 				// fields are single characters
659 				if ( nEnd == nStart+1 &&
660 					 ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
661 					 ( nPar < aSel.nEndPara   || nEnd   <= aSel.nEndPos ) )
662 				{
663 					ESelection aFieldSel( (sal_uInt16)nPar, nStart, (sal_uInt16)nPar, nEnd );
664 					SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
665 					if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SFX_ITEM_ON )
666 					{
667 						if (!bChanged)
668 						{
669 							if (bUpdate)
670 								pOutliner->SetUpdateMode( sal_False );
671 							String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
672 							pOutliner->GetUndoManager().EnterListAction( aName, aName );
673 							bChanged = sal_True;
674 						}
675 
676 						String aFieldText = rEditEng.GetText( aFieldSel );
677 						pOutliner->QuickInsertText( aFieldText, aFieldSel );
678 						if ( nPar == aSel.nEndPara )
679 						{
680                             nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.Len() );
681 							--nNewEnd;
682 						}
683 					}
684 				}
685 			}
686 		}
687 
688 	if (bUpdate && bChanged)
689 	{
690 		pOutliner->GetUndoManager().LeaveListAction();
691 		pOutliner->SetUpdateMode( sal_True );
692 	}
693 
694 	if ( aOldSel.IsEqual( aSel ) )			// aSel is adjusted
695 		aOldSel.nEndPos = nNewEnd;
696 	else
697 		aOldSel.nStartPos = nNewEnd;		// if aOldSel is backwards
698 	rOutView.SetSelection( aOldSel );
699 }
700 
701 void __EXPORT ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
702 {
703 	SdrView*			pView = pViewData->GetScDrawView();
704 	const SfxItemSet*	pArgs = rReq.GetArgs();
705 	sal_uInt16				nSlot = rReq.GetSlot();
706 
707 	sal_Bool bArgsInReq = ( pArgs != NULL );
708 	if ( !bArgsInReq )
709 	{
710 		SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
711 		pView->GetAttributes(aEditAttr);
712 		SfxItemSet	aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
713 		sal_Bool		bDone = sal_True;
714 
715 		switch ( nSlot )
716 		{
717 			case SID_TEXT_STANDARD:	// Harte Textattributierung loeschen
718 			{
719 				OutlinerView* pOutView = pView->IsTextEdit() ?
720 								pView->GetTextEditOutlinerView() : NULL;
721 				if ( pOutView )
722 					pOutView->Paint( Rectangle() );
723 
724 				SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END );
725 				pView->SetAttributes( aEmptyAttr, sal_True );
726 
727 				if ( pOutView )
728 				{
729 					lcl_RemoveFields( *pOutView );
730 					pOutView->ShowCursor();
731 				}
732 
733 				rReq.Done( aEmptyAttr );
734 				pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
735 				bDone = sal_False; // bereits hier passiert
736 			}
737 			break;
738 
739 			case SID_CHAR_DLG_EFFECT:
740 			case SID_CHAR_DLG:						// Dialog-Button
741 			case SID_ATTR_CHAR_FONT:				// Controller nicht angezeigt
742 			case SID_ATTR_CHAR_FONTHEIGHT:
743 				bDone = ExecuteCharDlg( aEditAttr, aNewAttr , nSlot);
744 				break;
745 
746 			case SID_PARA_DLG:
747 				bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
748 				break;
749 
750 			case SID_ATTR_CHAR_WEIGHT:
751 				aNewAttr.Put( (const SvxWeightItem&)aEditAttr.Get( EE_CHAR_WEIGHT ) );
752 				break;
753 
754 			case SID_ATTR_CHAR_POSTURE:
755 				aNewAttr.Put( (const SvxPostureItem&)aEditAttr.Get( EE_CHAR_ITALIC ) );
756 				break;
757 
758 			case SID_ATTR_CHAR_UNDERLINE:
759 				aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) );
760 				break;
761 
762 			case SID_ATTR_CHAR_OVERLINE:
763 				aNewAttr.Put( (const SvxOverlineItem&)aEditAttr.Get( EE_CHAR_OVERLINE ) );
764 				break;
765 
766 			case SID_ATTR_CHAR_CONTOUR:
767 				aNewAttr.Put( (const SvxContourItem&)aEditAttr.Get( EE_CHAR_OUTLINE ) );
768 				break;
769 
770 			case SID_ATTR_CHAR_SHADOWED:
771 				aNewAttr.Put( (const SvxShadowedItem&)aEditAttr.Get( EE_CHAR_SHADOW ) );
772 				break;
773 
774 			case SID_ATTR_CHAR_STRIKEOUT:
775 				aNewAttr.Put( (const SvxCrossedOutItem&)aEditAttr.Get( EE_CHAR_STRIKEOUT ) );
776 				break;
777 
778 			case SID_ALIGNLEFT:
779             case SID_ALIGN_ANY_LEFT:
780 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
781 				break;
782 
783 			case SID_ALIGNCENTERHOR:
784             case SID_ALIGN_ANY_HCENTER:
785 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
786 				break;
787 
788 			case SID_ALIGNRIGHT:
789             case SID_ALIGN_ANY_RIGHT:
790 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
791 				break;
792 
793 			case SID_ALIGNBLOCK:
794             case SID_ALIGN_ANY_JUSTIFIED:
795 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
796 				break;
797 
798 			case SID_ATTR_PARA_LINESPACE_10:
799 				{
800 					SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL );
801 					aItem.SetPropLineSpace( 100 );
802 					aNewAttr.Put( aItem );
803 				}
804 				break;
805 
806 			case SID_ATTR_PARA_LINESPACE_15:
807 				{
808 					SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL );
809 					aItem.SetPropLineSpace( 150 );
810 					aNewAttr.Put( aItem );
811 				}
812 				break;
813 
814 			case SID_ATTR_PARA_LINESPACE_20:
815 				{
816 					SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
817 					aItem.SetPropLineSpace( 200 );
818 					aNewAttr.Put( aItem );
819 				}
820 				break;
821 
822 			case SID_SET_SUPER_SCRIPT:
823 				{
824 					SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
825 					SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
826 									aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
827 
828 					if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
829 						aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
830 					else
831 						aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
832 					aNewAttr.Put( aItem );
833 				}
834 				break;
835 			case SID_SET_SUB_SCRIPT:
836 				{
837 					SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
838 					SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
839 									aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
840 
841 					if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
842 						aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
843 					else
844 						aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
845 					aNewAttr.Put( aItem );
846 				}
847 				break;
848 
849 			case SID_DRAWTEXT_ATTR_DLG:
850 				{
851 					SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
852 					SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView );
853 
854 					bDone = ( RET_OK == pDlg->Execute() );
855 
856 					if ( bDone )
857 						aNewAttr.Put( *pDlg->GetOutputItemSet() );
858 
859 					delete pDlg;
860 
861 					SfxBindings& rBindings = pViewData->GetBindings();
862 					rBindings.Invalidate( SID_TABLE_VERT_NONE );
863 					rBindings.Invalidate( SID_TABLE_VERT_CENTER );
864 					rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
865 				}
866 				break;
867 		}
868 
869 		if ( bDone ) // wurden Attribute geaendert?
870 		{
871 			rReq.Done( aNewAttr );
872 			pArgs = rReq.GetArgs();
873 		}
874 	}
875 
876 	if ( pArgs )
877 	{
878 		if ( bArgsInReq &&
879 			( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
880 			  nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
881 		{
882 			// font items from toolbox controller have to be applied for the right script type
883 
884 			// #i78017 establish the same behaviour as in Writer
885 			sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
886 			if (nSlot == SID_ATTR_CHAR_FONT)
887 				nScript = pView->GetScriptType();
888 
889 			SfxItemPool& rPool = GetPool();
890 			SvxScriptSetItem aSetItem( nSlot, rPool );
891 			sal_uInt16 nWhich = rPool.GetWhich( nSlot );
892 			aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
893 
894 			pView->SetAttributes( aSetItem.GetItemSet() );
895 		}
896 		else if( nSlot == SID_ATTR_PARA_LRSPACE )
897 		{
898 			sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
899 			const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&)
900 				pArgs->Get( nId );
901 			SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
902 			nId = EE_PARA_LRSPACE;
903 			SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
904 				rItem.GetRight(), rItem.GetTxtLeft(),
905 				rItem.GetTxtFirstLineOfst(), nId );
906 			aEditAttr.Put( aLRSpaceItem );
907 //			rReq.Done( aEditAttr );
908 //			pArgs = rReq.GetArgs();
909 //			pView->SetAttributes( *pArgs );
910 			pView->SetAttributes( aEditAttr );
911 //			Invalidate(SID_ATTR_PARA_LRSPACE);
912 		}
913 		else if( nSlot == SID_ATTR_PARA_LINESPACE )
914 		{
915 			sal_uInt16 nId = SID_ATTR_PARA_LINESPACE;
916 			SvxLineSpacingItem aLineSpaceItem = (const SvxLineSpacingItem&)pArgs->Get(
917 																GetPool().GetWhich(nSlot));
918 			SfxItemSet aEditAttr( GetPool(), EE_PARA_SBL, EE_PARA_SBL );
919 			aEditAttr.Put( aLineSpaceItem );
920 //			rReq.Done( aEditAttr );
921 //			pArgs = rReq.GetArgs();
922 //			pView->SetAttributes( *pArgs );
923 			pView->SetAttributes( aEditAttr );
924 //			Invalidate(SID_ATTR_PARA_LINESPACE);
925 		}
926 		else if( nSlot == SID_ATTR_PARA_ULSPACE )
927 		{
928 			sal_uInt16 nId = SID_ATTR_PARA_ULSPACE;
929 			SvxULSpaceItem aULSpaceItem = (const SvxULSpaceItem&)pArgs->Get(
930 																GetPool().GetWhich(nSlot));
931 			SfxItemSet aEditAttr( GetPool(), EE_PARA_ULSPACE, EE_PARA_ULSPACE );
932 			aULSpaceItem.SetWhich(EE_PARA_ULSPACE);
933 			aEditAttr.Put( aULSpaceItem );
934 //			rReq.Done( aEditAttr );
935 //			pArgs = rReq.GetArgs();
936 //			pView->SetAttributes( *pArgs );
937 			pView->SetAttributes( aEditAttr );
938 //			Invalidate(SID_ATTR_PARA_ULSPACE);
939 		}
940 		else if(nSlot ==  SID_SET_SUPER_SCRIPT )
941 		{
942 			SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
943 			pView->GetAttributes(aEditAttr);
944 			SfxItemSet	aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
945 
946 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
947 			SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
948 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
949 
950 			if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
951 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
952 			else
953 				aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
954 			aNewAttr.Put( aItem );
955 			pView->SetAttributes( aNewAttr );
956 		}
957 		else if( nSlot ==  SID_SET_SUB_SCRIPT )
958 		{
959 			SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
960 			pView->GetAttributes(aEditAttr);
961 			SfxItemSet	aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
962 
963 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
964 			SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
965 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
966 
967 			if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
968 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
969 			else
970 				aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
971 			aNewAttr.Put( aItem );
972 			pView->SetAttributes( aNewAttr );
973 		}
974 
975 		else if (bArgsInReq &&
976 			( nSlot == SID_TABLE_VERT_NONE || nSlot == SID_TABLE_VERT_CENTER ||
977 			  nSlot == SID_TABLE_VERT_BOTTOM ) )
978 		{
979 			SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
980 			if (nSlot == SID_TABLE_VERT_CENTER)
981 				eTVA = SDRTEXTVERTADJUST_CENTER;
982 			else if (nSlot == SID_TABLE_VERT_BOTTOM)
983 				eTVA = SDRTEXTVERTADJUST_BOTTOM;
984 
985 			SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
986 			SfxItemSet	aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
987 			aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
988 			pView->SetAttributes(aNewAttr);
989 		}
990 		else if (bArgsInReq &&
991 			(nSlot == SID_ATTR_PARA_ADJUST_LEFT || nSlot == SID_ATTR_PARA_ADJUST_CENTER || nSlot == SID_ATTR_PARA_ADJUST_RIGHT || nSlot == SID_ATTR_PARA_ADJUST_BLOCK ))
992 		{
993 			SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
994 			SfxItemSet	aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
995 			switch ( nSlot )
996 			{
997 			case SID_ATTR_PARA_ADJUST_LEFT:
998 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
999 				break;
1000 			case SID_ATTR_PARA_ADJUST_CENTER:
1001 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
1002 				break;
1003 			case SID_ATTR_PARA_ADJUST_RIGHT:
1004 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
1005 				break;
1006 			case SID_ATTR_PARA_ADJUST_BLOCK:
1007 				aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
1008 				break;
1009 			}
1010 			pView->SetAttributes(aNewAttr);
1011 		}
1012 		else
1013 		{
1014 			// use args directly
1015 
1016 			pView->SetAttributes( *pArgs );
1017 		}
1018 		pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
1019 	}
1020 }
1021 
1022 void __EXPORT ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet )
1023 {
1024 	if ( IsNoteEdit() )
1025 	{
1026 	    // issue 21255 - Notes now support rich text formatting.
1027 	}
1028 
1029 	SvtLanguageOptions	aLangOpt;
1030 	sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
1031 	sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
1032 
1033 	SdrView* pView = pViewData->GetScDrawView();
1034 	SfxItemSet aAttrSet(pView->GetModel()->GetItemPool());
1035 	pView->GetAttributes(aAttrSet);
1036 
1037 	//	direkte Attribute
1038 
1039 	rDestSet.Put( aAttrSet );
1040 
1041 	//	choose font info according to selection script type
1042 
1043 	sal_uInt16 nScript = pView->GetScriptType();
1044 
1045     // #i55929# input-language-dependent script type (depends on input language if nothing selected)
1046     sal_uInt16 nInputScript = nScript;
1047     OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1048     if (pOutView && !pOutView->GetSelection().HasRange())
1049     {
1050         LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
1051         if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
1052             nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
1053     }
1054 
1055     // #i55929# according to spec, nInputScript is used for font and font height only
1056 	if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
1057 		ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
1058 	if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
1059 		ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
1060 	if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
1061 		ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
1062 	if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
1063 		ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
1064 	//	Ausrichtung
1065 
1066 	SvxAdjust eAdj = ((const SvxAdjustItem&)aAttrSet.Get(EE_PARA_JUST)).GetAdjust();
1067 	switch( eAdj )
1068 	{
1069 	case SVX_ADJUST_LEFT:
1070 		{
1071 			rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, sal_True ) );
1072 			rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, sal_True ) );
1073 		}
1074 		break;
1075 	case SVX_ADJUST_CENTER:
1076 		{
1077 			rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, sal_True ) );
1078 			rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, sal_True ) );
1079 		}
1080 		break;
1081 	case SVX_ADJUST_RIGHT:
1082 		{
1083 			rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, sal_True ) );
1084 			rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, sal_True ) );
1085 		}
1086 		break;
1087 	case SVX_ADJUST_BLOCK:
1088 		{
1089 			rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, sal_True ) );
1090 			rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, sal_True ) );
1091 		}
1092 		break;
1093         default:
1094         {
1095             // added to avoid warnings
1096         }
1097 	}
1098     // pseudo slots for Format menu
1099     rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT,      eAdj == SVX_ADJUST_LEFT ) );
1100     rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER,   eAdj == SVX_ADJUST_CENTER ) );
1101     rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT,     eAdj == SVX_ADJUST_RIGHT ) );
1102     rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) );
1103 
1104     	SvxLRSpaceItem aLR = ((const SvxLRSpaceItem&)aAttrSet.Get( EE_PARA_LRSPACE ));
1105 	aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
1106 	rDestSet.Put(aLR);
1107 	Invalidate( SID_ATTR_PARA_LRSPACE );
1108 	SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
1109 	if ( eState == SFX_ITEM_DONTCARE )
1110 		rDestSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
1111 	//xuxu for Line Space
1112 	SvxLineSpacingItem aLineSP = ((const SvxLineSpacingItem&)aAttrSet.
1113 						Get( EE_PARA_SBL ));
1114 	aLineSP.SetWhich(SID_ATTR_PARA_LINESPACE);
1115 	rDestSet.Put(aLineSP);
1116 	Invalidate(SID_ATTR_PARA_LINESPACE);
1117 	eState = aAttrSet.GetItemState( EE_PARA_SBL );
1118 	if ( eState == SFX_ITEM_DONTCARE )
1119 		rDestSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
1120 	//xuxu for UL Space
1121 	SvxULSpaceItem aULSP = ((const SvxULSpaceItem&)aAttrSet.
1122 						Get( EE_PARA_ULSPACE ));
1123 	aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
1124 	rDestSet.Put(aULSP);
1125 	Invalidate(SID_ATTR_PARA_ULSPACE);
1126 	eState = aAttrSet.GetItemState( EE_PARA_ULSPACE );
1127 	if ( eState == SFX_ITEM_DONTCARE )
1128 		rDestSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
1129 
1130 	//	Zeilenabstand
1131 
1132 	sal_uInt16 nLineSpace = (sal_uInt16)
1133 				((const SvxLineSpacingItem&)aAttrSet.
1134 						Get( EE_PARA_SBL )).GetPropLineSpace();
1135 	switch( nLineSpace )
1136 	{
1137 		case 100:
1138 			rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, sal_True ) );
1139 			break;
1140 		case 150:
1141 			rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, sal_True ) );
1142 			break;
1143 		case 200:
1144 			rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, sal_True ) );
1145 			break;
1146 	}
1147 
1148 	//	hoch-/tiefgestellt
1149 
1150 	SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
1151 					aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1152 	if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
1153 		rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) );
1154 	else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
1155 		rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) );
1156 
1157 	//	Unterstreichung
1158 
1159 	eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, sal_True );
1160 	if ( eState == SFX_ITEM_DONTCARE )
1161 	{
1162 		rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
1163 		rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1164 		rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1165 		rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1166 	}
1167 	else
1168 	{
1169 		FontUnderline eUnderline = ((const SvxUnderlineItem&)
1170 					aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
1171 		sal_uInt16 nId = SID_ULINE_VAL_NONE;
1172 		switch (eUnderline)
1173 		{
1174 			case UNDERLINE_SINGLE:	nId = SID_ULINE_VAL_SINGLE;	break;
1175 			case UNDERLINE_DOUBLE:	nId = SID_ULINE_VAL_DOUBLE;	break;
1176 			case UNDERLINE_DOTTED:	nId = SID_ULINE_VAL_DOTTED;	break;
1177 			default:
1178 				break;
1179 		}
1180 		rDestSet.Put( SfxBoolItem( nId, sal_True ) );
1181 	}
1182 
1183 	//	horizontal / vertical
1184 
1185 	sal_Bool bLeftToRight = sal_True;
1186 
1187 	SdrOutliner* pOutl = pView->GetTextEditOutliner();
1188 	if( pOutl )
1189 	{
1190 		if( pOutl->IsVertical() )
1191 			bLeftToRight = sal_False;
1192 	}
1193 	else
1194 		bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
1195 
1196 	if ( bDisableVerticalText )
1197 	{
1198 		rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
1199 		rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
1200 	}
1201 	else
1202 	{
1203 		rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
1204 		rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
1205 	}
1206 
1207 	//	left-to-right or right-to-left
1208 
1209 	if ( !bLeftToRight || bDisableCTLFont )
1210 	{
1211 		//	disabled if vertical
1212 		rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1213 		rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1214 	}
1215 	else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SFX_ITEM_DONTCARE )
1216 	{
1217 		rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1218 		rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1219 	}
1220 	else
1221 	{
1222 	    SvxFrameDirection eAttrDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
1223 	                                    aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue();
1224 	    if ( eAttrDir == FRMDIR_ENVIRONMENT )
1225 	    {
1226 	    	//	get "environment" direction from page style
1227 	    	if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L )
1228 		    	eAttrDir = FRMDIR_HORI_RIGHT_TOP;
1229 		    else
1230 		    	eAttrDir = FRMDIR_HORI_LEFT_TOP;
1231 	    }
1232 		rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) );
1233 		rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) );
1234 	}
1235 }
1236 
1237 void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq )
1238 {
1239 	sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
1240 	if ( nType )
1241 	{
1242 		ScDrawView* pView = pViewData->GetScDrawView();
1243 		OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1244 		if ( pOutView )
1245 		{
1246 			//	change selected text in object
1247 			pOutView->TransliterateText( nType );
1248 		}
1249 		else
1250 		{
1251 			//!	apply to whole objects?
1252 		}
1253 	}
1254 }
1255 
1256 void ScDrawTextObjectBar::GetStatePropPanelAttr(SfxItemSet &rSet)
1257 {
1258 	SfxWhichIter	aIter( rSet );
1259 	sal_uInt16			nWhich = aIter.FirstWhich();
1260 
1261 	SdrView*			pView = pViewData->GetScDrawView();
1262 
1263 	SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
1264 	pView->GetAttributes(aEditAttr);
1265 	//SfxItemSet	aAttrs( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
1266 
1267 	while ( nWhich )
1268 	{
1269 		sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1270 			? GetPool().GetSlotId(nWhich)
1271 			: nWhich;
1272 		switch ( nSlotId )
1273 		{
1274 			case SID_TABLE_VERT_NONE:
1275 			case SID_TABLE_VERT_CENTER:
1276 			case SID_TABLE_VERT_BOTTOM:
1277 				sal_Bool bContour = sal_False;
1278 				SfxItemState eConState = aEditAttr.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1279 				if( eConState != SFX_ITEM_DONTCARE )
1280 				{
1281 					bContour = ( ( const SdrTextContourFrameItem& )aEditAttr.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
1282 				}
1283 				if (bContour) break;
1284 
1285 				SfxItemState eVState = aEditAttr.GetItemState( SDRATTR_TEXT_VERTADJUST );
1286 				//SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1287 
1288 				//if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
1289 				if(SFX_ITEM_DONTCARE != eVState)
1290 				{
1291 					SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aEditAttr.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
1292 					sal_Bool bSet = nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP||
1293                             nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER ||
1294                             nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM;
1295 					rSet.Put(SfxBoolItem(nSlotId, bSet));
1296 				}
1297 				else
1298 				{
1299 					rSet.Put(SfxBoolItem(nSlotId, sal_False));
1300 				}
1301 				break;
1302 		}
1303 		nWhich = aIter.NextWhich();
1304 	}
1305 }
1306 
1307