bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / drawfunc / drtxtob.cxx
blob8e97dd2bc6e6cadb7eb506e10daf24acee5ae71c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/linguistic2/XThesaurus.hpp>
21 #include <com/sun/star/lang/Locale.hpp>
22 #include <comphelper/string.hxx>
23 #include "scitems.hxx"
25 #include <editeng/adjustitem.hxx>
26 #include <svx/clipfmtitem.hxx>
27 #include <editeng/contouritem.hxx>
28 #include <editeng/crossedoutitem.hxx>
29 #include <editeng/editeng.hxx>
30 #include <editeng/escapementitem.hxx>
31 #include <editeng/flditem.hxx>
32 #include <editeng/fontitem.hxx>
33 #include <editeng/frmdiritem.hxx>
34 #include <editeng/lrspitem.hxx>
35 #include <editeng/lspcitem.hxx>
36 #include <editeng/ulspitem.hxx>
37 #include <svx/hlnkitem.hxx>
38 #include <editeng/lspcitem.hxx>
39 #include <svx/svdoutl.hxx>
40 #include <editeng/unolingu.hxx>
41 #include <editeng/outlobj.hxx>
42 #include <editeng/postitem.hxx>
43 #include <editeng/scripttypeitem.hxx>
44 #include <editeng/shdditem.hxx>
45 #include <svl/srchitem.hxx>
46 #include <editeng/udlnitem.hxx>
47 #include <editeng/wghtitem.hxx>
48 #include <editeng/writingmodeitem.hxx>
49 #include <sfx2/app.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <sfx2/objface.hxx>
52 #include <sfx2/objsh.hxx>
53 #include <sfx2/request.hxx>
54 #include <sfx2/viewfrm.hxx>
55 #include <svtools/cliplistener.hxx>
56 #include <svtools/transfer.hxx>
57 #include <svl/whiter.hxx>
58 #include <svl/languageoptions.hxx>
59 #include <vcl/msgbox.hxx>
61 #include <svx/svxdlg.hxx>
62 #include <svx/dialogs.hrc>
63 #include <sfx2/sidebar/EnumContext.hxx>
65 #include "sc.hrc"
66 #include "globstr.hrc"
67 #include "scmod.hxx"
68 #include "drtxtob.hxx"
69 #include "fudraw.hxx"
70 #include "viewdata.hxx"
71 #include "document.hxx"
72 #include "drawview.hxx"
73 #include "viewutil.hxx"
74 #include "scresid.hxx"
75 #include "tabvwsh.hxx"
77 #define ScDrawTextObjectBar
78 #include "scslots.hxx"
81 using namespace ::com::sun::star;
84 SFX_IMPL_INTERFACE( ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL) )
86 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
87 ScResId(RID_TEXT_TOOLBOX) );
88 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT) );
89 SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() );
92 TYPEINIT1( ScDrawTextObjectBar, SfxShell );
96 // abschalten der nicht erwuenschten Acceleratoren:
98 void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
100 SfxWhichIter aIter(rSet);
101 sal_uInt16 nWhich = aIter.FirstWhich();
103 while (nWhich)
105 rSet.DisableItem( nWhich );
106 nWhich = aIter.NextWhich();
110 ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
111 SfxShell(pData->GetViewShell()),
112 pViewData(pData),
113 pClipEvtLstnr(NULL),
114 bPastePossible(false)
116 SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
118 // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt...
119 ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
120 SetUndoManager( pMgr );
121 if ( !pViewData->GetDocument()->IsUndoEnabled() )
123 pMgr->SetMaxUndoActionCount( 0 );
126 SetHelpId( HID_SCSHELL_DRTXTOB );
127 SetName(OUString("DrawText"));
128 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText));
131 ScDrawTextObjectBar::~ScDrawTextObjectBar()
133 if ( pClipEvtLstnr )
135 pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
137 // The listener may just now be waiting for the SolarMutex and call the link
138 // afterwards, in spite of RemoveListener. So the link has to be reset, too.
139 pClipEvtLstnr->ClearCallbackLink();
141 pClipEvtLstnr->release();
145 //========================================================================
147 // Funktionen
149 //========================================================================
151 void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
153 ScDrawView* pView = pViewData->GetScDrawView();
154 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
155 Outliner* pOutliner = pView->GetTextEditOutliner();
157 if (!pOutView || !pOutliner)
159 ExecuteGlobal( rReq ); // auf ganze Objekte
160 return;
163 const SfxItemSet* pReqArgs = rReq.GetArgs();
164 sal_uInt16 nSlot = rReq.GetSlot();
165 switch ( nSlot )
167 case SID_COPY:
168 pOutView->Copy();
169 break;
171 case SID_CUT:
172 pOutView->Cut();
173 break;
175 case SID_PASTE:
176 pOutView->PasteSpecial();
177 break;
179 case SID_CLIPBOARD_FORMAT_ITEMS:
181 sal_uLong nFormat = 0;
182 const SfxPoolItem* pItem;
183 if ( pReqArgs &&
184 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
185 pItem->ISA(SfxUInt32Item) )
187 nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
190 if ( nFormat )
192 if (nFormat == SOT_FORMAT_STRING)
193 pOutView->Paste();
194 else
195 pOutView->PasteSpecial();
198 break;
200 case SID_PASTE_SPECIAL:
201 ExecutePasteContents( rReq );
202 break;
204 case SID_SELECTALL:
206 sal_Int32 nCount = pOutliner->GetParagraphCount();
207 ESelection aSel( 0,0,nCount,0 );
208 pOutView->SetSelection( aSel );
210 break;
212 case SID_CHARMAP:
214 const SvxFontItem& rItem = (const SvxFontItem&)
215 pOutView->GetAttribs().Get(EE_CHAR_FONTINFO);
217 String aString;
218 SvxFontItem aNewItem( EE_CHAR_FONTINFO );
220 const SfxItemSet *pArgs = rReq.GetArgs();
221 const SfxPoolItem* pItem = 0;
222 if( pArgs )
223 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
225 if ( pItem )
227 aString = ((const SfxStringItem*)pItem)->GetValue();
228 const SfxPoolItem* pFtItem = NULL;
229 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
230 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
231 if ( pFontItem )
233 String aFontName(pFontItem->GetValue());
234 Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
235 aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
236 aFont.GetStyleName(), aFont.GetPitch(),
237 aFont.GetCharSet(), ATTR_FONT );
239 else
240 aNewItem = rItem;
242 else
243 ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
245 if ( aString.Len() )
247 SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
248 aSet.Put( aNewItem );
249 // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
250 pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() );
251 pOutView->InsertText(aString);
254 Invalidate( SID_ATTR_CHAR_FONT );
256 break;
258 case SID_HYPERLINK_SETLINK:
259 if( pReqArgs )
261 const SfxPoolItem* pItem;
262 if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
264 const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
265 const String& rName = pHyper->GetName();
266 const String& rURL = pHyper->GetURL();
267 const String& rTarget = pHyper->GetTargetFrame();
268 SvxLinkInsertMode eMode = pHyper->GetInsertMode();
270 sal_Bool bDone = false;
271 if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) )
273 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
274 if (pFieldItem)
276 const SvxFieldData* pField = pFieldItem->GetField();
277 if ( pField && pField->ISA(SvxURLField) )
279 // altes Feld selektieren
281 ESelection aSel = pOutView->GetSelection();
282 aSel.Adjust();
283 aSel.nEndPara = aSel.nStartPara;
284 aSel.nEndPos = aSel.nStartPos + 1;
285 pOutView->SetSelection( aSel );
289 // neues Feld einfuegen
291 SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
292 aURLField.SetTargetFrame( rTarget );
293 SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
294 pOutView->InsertField( aURLItem );
296 // select new field
298 ESelection aSel = pOutView->GetSelection();
299 if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 )
301 // Cursor is behind the inserted field -> extend selection to the left
303 --aSel.nStartPos;
304 pOutView->SetSelection( aSel );
307 bDone = sal_True;
310 if (!bDone)
311 ExecuteGlobal( rReq ); // normal an der View
313 // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
316 break;
318 case SID_OPEN_HYPERLINK:
320 if ( pOutView )
322 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
323 if ( pFieldItem )
325 const SvxFieldData* pField = pFieldItem->GetField();
326 if( pField && pField->ISA( SvxURLField ) )
328 const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
329 ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
334 break;
336 case SID_ENABLE_HYPHENATION:
337 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
338 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
339 pView->ScEndTextEdit(); // end text edit before switching direction
340 ExecuteGlobal( rReq );
341 // restore consistent state between shells and functions:
342 pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
343 break;
345 case SID_THES:
347 String aReplaceText;
348 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, false );
349 if (pItem2)
350 aReplaceText = pItem2->GetValue();
351 if (aReplaceText.Len() > 0)
352 ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
354 break;
356 case SID_THESAURUS:
358 pOutView->StartThesaurus();
360 break;
365 void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
367 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
368 sal_Bool bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK);
369 sal_Bool bDisableFontWork = false;
371 if (IsNoteEdit())
373 // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
374 bDisableFontWork = sal_True;
377 if ( bDisableFontWork )
378 rSet.DisableItem( SID_FONTWORK );
379 else
380 rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
382 if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SFX_ITEM_UNKNOWN )
384 SvxHyperlinkItem aHLinkItem;
385 SdrView* pView = pViewData->GetScDrawView();
386 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
387 if ( pOutView )
389 sal_Bool bField = false;
390 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
391 if (pFieldItem)
393 const SvxFieldData* pField = pFieldItem->GetField();
394 if ( pField && pField->ISA(SvxURLField) )
396 const SvxURLField* pURLField = (const SvxURLField*) pField;
397 aHLinkItem.SetName( pURLField->GetRepresentation() );
398 aHLinkItem.SetURL( pURLField->GetURL() );
399 aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
400 bField = sal_True;
403 if (!bField)
405 // use selected text as name for urls
406 String sReturn = pOutView->GetSelected();
407 sReturn.Erase(255);
408 aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
411 rSet.Put(aHLinkItem);
414 if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SFX_ITEM_UNKNOWN )
416 SdrView* pView = pViewData->GetScDrawView();
417 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
418 bool bEnable = false;
419 if ( pOutView )
421 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
422 if ( pFieldItem )
424 const SvxFieldData* pField = pFieldItem->GetField();
425 bEnable = pField && pField->ISA( SvxURLField );
428 if( !bEnable )
429 rSet.DisableItem( SID_OPEN_HYPERLINK );
432 if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SFX_ITEM_UNKNOWN )
433 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
434 if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SFX_ITEM_UNKNOWN )
435 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
436 if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SFX_ITEM_UNKNOWN )
437 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA );
438 if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SFX_ITEM_UNKNOWN )
439 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA );
441 if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN )
443 SdrView* pView = pViewData->GetScDrawView();
444 SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
445 pView->GetAttributes( aAttrs );
446 if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
448 sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
449 rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
453 if ( rSet.GetItemState( SID_THES ) != SFX_ITEM_UNKNOWN ||
454 rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN )
456 SdrView * pView = pViewData->GetScDrawView();
457 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
459 String aStatusVal;
460 LanguageType nLang = LANGUAGE_NONE;
461 bool bIsLookUpWord = false;
462 if ( pOutView )
464 EditView& rEditView = pOutView->GetEditView();
465 bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
467 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
469 // disable thesaurus main menu and context menu entry if there is nothing to look up
470 sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
471 if (!bIsLookUpWord || !bCanDoThesaurus)
472 rSet.DisableItem( SID_THES );
473 if (!bCanDoThesaurus)
474 rSet.DisableItem( SID_THESAURUS );
478 IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper )
480 if ( pDataHelper )
482 bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
484 SfxBindings& rBindings = pViewData->GetBindings();
485 rBindings.Invalidate( SID_PASTE );
486 rBindings.Invalidate( SID_PASTE_SPECIAL );
487 rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
489 return 0;
492 void ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
494 SdrView* pView = pViewData->GetScDrawView();
495 if ( !pView->GetTextEditOutlinerView() )
497 GetGlobalClipState( rSet );
498 return;
501 if ( !pClipEvtLstnr )
503 // create listener
504 pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
505 pClipEvtLstnr->acquire();
506 Window* pWin = pViewData->GetActiveWin();
507 pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
509 // get initial state
510 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
511 bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
514 SfxWhichIter aIter( rSet );
515 sal_uInt16 nWhich = aIter.FirstWhich();
516 while (nWhich)
518 switch (nWhich)
520 case SID_PASTE:
521 case SID_PASTE_SPECIAL:
522 if( !bPastePossible )
523 rSet.DisableItem( nWhich );
524 break;
525 case SID_CLIPBOARD_FORMAT_ITEMS:
526 if ( bPastePossible )
528 SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
529 TransferableDataHelper aDataHelper(
530 TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
532 if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
533 aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
534 if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
535 aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
537 rSet.Put( aFormats );
539 else
540 rSet.DisableItem( nWhich );
541 break;
543 nWhich = aIter.NextWhich();
547 //========================================================================
549 // Attribute
551 //========================================================================
553 void ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq )
555 // Unterstreichung
557 SdrView* pView = pViewData->GetScDrawView();
559 sal_uInt16 nSlot = rReq.GetSlot();
561 SfxItemSet aSet( pView->GetDefaultAttr() );
563 SfxItemSet aViewAttr(pView->GetModel()->GetItemPool());
564 pView->GetAttributes(aViewAttr);
566 // Unterstreichung
567 FontUnderline eOld = ((const SvxUnderlineItem&) aViewAttr.
568 Get(EE_CHAR_UNDERLINE)).GetLineStyle();
569 FontUnderline eNew = eOld;
570 switch (nSlot)
572 case SID_ULINE_VAL_NONE:
573 eNew = UNDERLINE_NONE;
574 break;
575 case SID_ULINE_VAL_SINGLE:
576 eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
577 break;
578 case SID_ULINE_VAL_DOUBLE:
579 eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
580 break;
581 case SID_ULINE_VAL_DOTTED:
582 eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
583 break;
584 default:
585 break;
587 aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
589 pView->SetAttributes( aSet );
590 rReq.Done();
591 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
594 static void lcl_RemoveFields( OutlinerView& rOutView )
596 //! Outliner should have RemoveFields with a selection
598 Outliner* pOutliner = rOutView.GetOutliner();
599 if (!pOutliner) return;
601 ESelection aOldSel = rOutView.GetSelection();
602 ESelection aSel = aOldSel;
603 aSel.Adjust();
604 xub_StrLen nNewEnd = aSel.nEndPos;
606 sal_Bool bUpdate = pOutliner->GetUpdateMode();
607 sal_Bool bChanged = false;
609 //! GetPortions and GetAttribs should be const!
610 EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
612 sal_Int32 nParCount = pOutliner->GetParagraphCount();
613 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
614 if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
616 std::vector<sal_uInt16> aPortions;
617 rEditEng.GetPortions( nPar, aPortions );
618 //! GetPortions should use xub_StrLen instead of USHORT
620 for ( size_t nPos = aPortions.size(); nPos; )
622 --nPos;
623 sal_uInt16 nEnd = aPortions[ nPos ];
624 sal_uInt16 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
625 // fields are single characters
626 if ( nEnd == nStart+1 &&
627 ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
628 ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) )
630 ESelection aFieldSel( nPar, nStart, nPar, nEnd );
631 SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
632 if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SFX_ITEM_ON )
634 if (!bChanged)
636 if (bUpdate)
637 pOutliner->SetUpdateMode( false );
638 String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
639 pOutliner->GetUndoManager().EnterListAction( aName, aName );
640 bChanged = sal_True;
643 String aFieldText = rEditEng.GetText( aFieldSel );
644 pOutliner->QuickInsertText( aFieldText, aFieldSel );
645 if ( nPar == aSel.nEndPara )
647 nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.Len() );
648 --nNewEnd;
655 if (bUpdate && bChanged)
657 pOutliner->GetUndoManager().LeaveListAction();
658 pOutliner->SetUpdateMode( sal_True );
661 if ( aOldSel.IsEqual( aSel ) ) // aSel is adjusted
662 aOldSel.nEndPos = nNewEnd;
663 else
664 aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards
665 rOutView.SetSelection( aOldSel );
668 void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
670 SdrView* pView = pViewData->GetScDrawView();
671 const SfxItemSet* pArgs = rReq.GetArgs();
672 sal_uInt16 nSlot = rReq.GetSlot();
674 sal_Bool bArgsInReq = ( pArgs != NULL );
675 if ( !bArgsInReq )
677 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
678 pView->GetAttributes(aEditAttr);
679 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
680 sal_Bool bDone = sal_True;
682 switch ( nSlot )
684 case SID_TEXT_STANDARD: // Harte Textattributierung loeschen
686 OutlinerView* pOutView = pView->IsTextEdit() ?
687 pView->GetTextEditOutlinerView() : NULL;
688 if ( pOutView )
689 pOutView->Paint( Rectangle() );
691 SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END );
692 pView->SetAttributes( aEmptyAttr, sal_True );
694 if ( pOutView )
696 lcl_RemoveFields( *pOutView );
697 pOutView->ShowCursor();
700 rReq.Done( aEmptyAttr );
701 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
702 bDone = false; // bereits hier passiert
704 break;
706 case SID_CHAR_DLG_EFFECT:
707 case SID_CHAR_DLG: // Dialog-Button
708 case SID_ATTR_CHAR_FONT: // Controller nicht angezeigt
709 case SID_ATTR_CHAR_FONTHEIGHT:
710 bDone = ExecuteCharDlg( aEditAttr, aNewAttr , nSlot);
711 break;
713 case SID_PARA_DLG:
714 bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
715 break;
717 case SID_ATTR_CHAR_WEIGHT:
718 aNewAttr.Put( (const SvxWeightItem&)aEditAttr.Get( EE_CHAR_WEIGHT ) );
719 break;
721 case SID_ATTR_CHAR_POSTURE:
722 aNewAttr.Put( (const SvxPostureItem&)aEditAttr.Get( EE_CHAR_ITALIC ) );
723 break;
725 case SID_ATTR_CHAR_UNDERLINE:
726 aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) );
727 break;
729 case SID_ATTR_CHAR_OVERLINE:
730 aNewAttr.Put( (const SvxOverlineItem&)aEditAttr.Get( EE_CHAR_OVERLINE ) );
731 break;
733 case SID_ATTR_CHAR_CONTOUR:
734 aNewAttr.Put( (const SvxContourItem&)aEditAttr.Get( EE_CHAR_OUTLINE ) );
735 break;
737 case SID_ATTR_CHAR_SHADOWED:
738 aNewAttr.Put( (const SvxShadowedItem&)aEditAttr.Get( EE_CHAR_SHADOW ) );
739 break;
741 case SID_ATTR_CHAR_STRIKEOUT:
742 aNewAttr.Put( (const SvxCrossedOutItem&)aEditAttr.Get( EE_CHAR_STRIKEOUT ) );
743 break;
745 case SID_ALIGNLEFT:
746 case SID_ALIGN_ANY_LEFT:
747 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
748 break;
750 case SID_ALIGNCENTERHOR:
751 case SID_ALIGN_ANY_HCENTER:
752 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
753 break;
755 case SID_ALIGNRIGHT:
756 case SID_ALIGN_ANY_RIGHT:
757 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
758 break;
760 case SID_ALIGNBLOCK:
761 case SID_ALIGN_ANY_JUSTIFIED:
762 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
763 break;
765 case SID_ATTR_PARA_LINESPACE_10:
767 SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL );
768 aItem.SetPropLineSpace( 100 );
769 aNewAttr.Put( aItem );
771 break;
773 case SID_ATTR_PARA_LINESPACE_15:
775 SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL );
776 aItem.SetPropLineSpace( 150 );
777 aNewAttr.Put( aItem );
779 break;
781 case SID_ATTR_PARA_LINESPACE_20:
783 SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
784 aItem.SetPropLineSpace( 200 );
785 aNewAttr.Put( aItem );
787 break;
789 case SID_SET_SUPER_SCRIPT:
791 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
792 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
793 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
795 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
796 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
797 else
798 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
799 aNewAttr.Put( aItem );
801 break;
802 case SID_SET_SUB_SCRIPT:
804 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
805 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
806 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
808 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
809 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
810 else
811 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
812 aNewAttr.Put( aItem );
814 break;
816 case SID_DRAWTEXT_ATTR_DLG:
818 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
819 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView );
821 bDone = ( RET_OK == pDlg->Execute() );
823 if ( bDone )
824 aNewAttr.Put( *pDlg->GetOutputItemSet() );
826 delete pDlg;
828 SfxBindings& rBindings = pViewData->GetBindings();
829 rBindings.Invalidate( SID_TABLE_VERT_NONE );
830 rBindings.Invalidate( SID_TABLE_VERT_CENTER );
831 rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
833 break;
836 if ( bDone ) // wurden Attribute geaendert?
838 rReq.Done( aNewAttr );
839 pArgs = rReq.GetArgs();
843 if ( pArgs )
845 if ( bArgsInReq &&
846 ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
847 nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
849 // font items from toolbox controller have to be applied for the right script type
851 // #i78017 establish the same behaviour as in Writer
852 sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
853 if (nSlot == SID_ATTR_CHAR_FONT)
854 nScript = pView->GetScriptType();
856 SfxItemPool& rPool = GetPool();
857 SvxScriptSetItem aSetItem( nSlot, rPool );
858 sal_uInt16 nWhich = rPool.GetWhich( nSlot );
859 aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
861 pView->SetAttributes( aSetItem.GetItemSet() );
863 else if( nSlot == SID_ATTR_PARA_LRSPACE )
865 sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
866 const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&)
867 pArgs->Get( nId );
868 SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
869 nId = EE_PARA_LRSPACE;
870 SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
871 rItem.GetRight(), rItem.GetTxtLeft(),
872 rItem.GetTxtFirstLineOfst(), nId );
873 aEditAttr.Put( aLRSpaceItem );
874 // rReq.Done( aEditAttr );
875 // pArgs = rReq.GetArgs();
876 // pView->SetAttributes( *pArgs );
877 pView->SetAttributes( aEditAttr );
878 // Invalidate(SID_ATTR_PARA_LRSPACE);
880 else if( nSlot == SID_ATTR_PARA_LINESPACE )
882 SvxLineSpacingItem aLineSpaceItem = (const SvxLineSpacingItem&)pArgs->Get(
883 GetPool().GetWhich(nSlot));
884 SfxItemSet aEditAttr( GetPool(), EE_PARA_SBL, EE_PARA_SBL );
885 aEditAttr.Put( aLineSpaceItem );
886 // rReq.Done( aEditAttr );
887 // pArgs = rReq.GetArgs();
888 // pView->SetAttributes( *pArgs );
889 pView->SetAttributes( aEditAttr );
890 // Invalidate(SID_ATTR_PARA_LINESPACE);
892 else if( nSlot == SID_ATTR_PARA_ULSPACE )
894 SvxULSpaceItem aULSpaceItem = (const SvxULSpaceItem&)pArgs->Get(
895 GetPool().GetWhich(nSlot));
896 SfxItemSet aEditAttr( GetPool(), EE_PARA_ULSPACE, EE_PARA_ULSPACE );
897 aULSpaceItem.SetWhich(EE_PARA_ULSPACE);
898 aEditAttr.Put( aULSpaceItem );
899 // rReq.Done( aEditAttr );
900 // pArgs = rReq.GetArgs();
901 // pView->SetAttributes( *pArgs );
902 pView->SetAttributes( aEditAttr );
903 // Invalidate(SID_ATTR_PARA_ULSPACE);
905 else if(nSlot == SID_SET_SUPER_SCRIPT )
907 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
908 pView->GetAttributes(aEditAttr);
909 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
911 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
912 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
913 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
915 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
916 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
917 else
918 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
919 aNewAttr.Put( aItem );
920 pView->SetAttributes( aNewAttr );
922 else if( nSlot == SID_SET_SUB_SCRIPT )
924 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
925 pView->GetAttributes(aEditAttr);
926 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
928 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
929 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
930 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
932 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
933 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
934 else
935 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
936 aNewAttr.Put( aItem );
937 pView->SetAttributes( aNewAttr );
940 else if (bArgsInReq &&
941 ( nSlot == SID_TABLE_VERT_NONE || nSlot == SID_TABLE_VERT_CENTER ||
942 nSlot == SID_TABLE_VERT_BOTTOM ) )
944 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
945 if (nSlot == SID_TABLE_VERT_CENTER)
946 eTVA = SDRTEXTVERTADJUST_CENTER;
947 else if (nSlot == SID_TABLE_VERT_BOTTOM)
948 eTVA = SDRTEXTVERTADJUST_BOTTOM;
950 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
951 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
952 aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
953 pView->SetAttributes(aNewAttr);
955 else if (bArgsInReq &&
956 (nSlot == SID_ATTR_PARA_ADJUST_LEFT || nSlot == SID_ATTR_PARA_ADJUST_CENTER || nSlot == SID_ATTR_PARA_ADJUST_RIGHT || nSlot == SID_ATTR_PARA_ADJUST_BLOCK ))
958 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
959 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
960 switch ( nSlot )
962 case SID_ATTR_PARA_ADJUST_LEFT:
963 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
964 break;
965 case SID_ATTR_PARA_ADJUST_CENTER:
966 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
967 break;
968 case SID_ATTR_PARA_ADJUST_RIGHT:
969 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
970 break;
971 case SID_ATTR_PARA_ADJUST_BLOCK:
972 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
973 break;
975 pView->SetAttributes(aNewAttr);
977 else
979 // use args directly
981 pView->SetAttributes( *pArgs );
983 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
987 void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet )
989 if ( IsNoteEdit() )
991 // issue 21255 - Notes now support rich text formatting.
994 SvtLanguageOptions aLangOpt;
995 sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
996 sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
998 SdrView* pView = pViewData->GetScDrawView();
999 SfxItemSet aAttrSet(pView->GetModel()->GetItemPool());
1000 pView->GetAttributes(aAttrSet);
1002 // direkte Attribute
1004 rDestSet.Put( aAttrSet );
1006 // choose font info according to selection script type
1008 sal_uInt16 nScript = pView->GetScriptType();
1010 // #i55929# input-language-dependent script type (depends on input language if nothing selected)
1011 sal_uInt16 nInputScript = nScript;
1012 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1013 if (pOutView && !pOutView->GetSelection().HasRange())
1015 LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
1016 if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
1017 nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
1020 // #i55929# according to spec, nInputScript is used for font and font height only
1021 if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
1022 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
1023 if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
1024 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
1025 if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
1026 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
1027 if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
1028 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
1029 // Ausrichtung
1031 SvxAdjust eAdj = ((const SvxAdjustItem&)aAttrSet.Get(EE_PARA_JUST)).GetAdjust();
1032 switch( eAdj )
1034 case SVX_ADJUST_LEFT:
1036 rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, sal_True ) );
1037 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, sal_True ) );
1039 break;
1040 case SVX_ADJUST_CENTER:
1042 rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, sal_True ) );
1043 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, sal_True ) );
1045 break;
1046 case SVX_ADJUST_RIGHT:
1048 rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, sal_True ) );
1049 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, sal_True ) );
1051 break;
1052 case SVX_ADJUST_BLOCK:
1054 rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, sal_True ) );
1055 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, sal_True ) );
1057 break;
1058 default:
1060 // added to avoid warnings
1063 // pseudo slots for Format menu
1064 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SVX_ADJUST_LEFT ) );
1065 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SVX_ADJUST_CENTER ) );
1066 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SVX_ADJUST_RIGHT ) );
1067 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) );
1069 SvxLRSpaceItem aLR = ((const SvxLRSpaceItem&)aAttrSet.Get( EE_PARA_LRSPACE ));
1070 aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
1071 rDestSet.Put(aLR);
1072 Invalidate( SID_ATTR_PARA_LRSPACE );
1073 SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
1074 if ( eState == SFX_ITEM_DONTCARE )
1075 rDestSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
1076 //xuxu for Line Space
1077 SvxLineSpacingItem aLineSP = ((const SvxLineSpacingItem&)aAttrSet.
1078 Get( EE_PARA_SBL ));
1079 aLineSP.SetWhich(SID_ATTR_PARA_LINESPACE);
1080 rDestSet.Put(aLineSP);
1081 Invalidate(SID_ATTR_PARA_LINESPACE);
1082 eState = aAttrSet.GetItemState( EE_PARA_SBL );
1083 if ( eState == SFX_ITEM_DONTCARE )
1084 rDestSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
1085 //xuxu for UL Space
1086 SvxULSpaceItem aULSP = ((const SvxULSpaceItem&)aAttrSet.
1087 Get( EE_PARA_ULSPACE ));
1088 aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
1089 rDestSet.Put(aULSP);
1090 Invalidate(SID_ATTR_PARA_ULSPACE);
1091 eState = aAttrSet.GetItemState( EE_PARA_ULSPACE );
1092 if ( eState == SFX_ITEM_DONTCARE )
1093 rDestSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
1095 // Zeilenabstand
1097 sal_uInt16 nLineSpace = (sal_uInt16)
1098 ((const SvxLineSpacingItem&)aAttrSet.
1099 Get( EE_PARA_SBL )).GetPropLineSpace();
1100 switch( nLineSpace )
1102 case 100:
1103 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, sal_True ) );
1104 break;
1105 case 150:
1106 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, sal_True ) );
1107 break;
1108 case 200:
1109 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, sal_True ) );
1110 break;
1113 // hoch-/tiefgestellt
1115 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
1116 aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1117 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
1118 rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) );
1119 else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
1120 rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) );
1122 // Unterstreichung
1124 eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, sal_True );
1125 if ( eState == SFX_ITEM_DONTCARE )
1127 rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
1128 rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1129 rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1130 rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1132 else
1134 FontUnderline eUnderline = ((const SvxUnderlineItem&)
1135 aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
1136 sal_uInt16 nId = SID_ULINE_VAL_NONE;
1137 switch (eUnderline)
1139 case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
1140 case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
1141 case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
1142 default:
1143 break;
1145 rDestSet.Put( SfxBoolItem( nId, sal_True ) );
1148 // horizontal / vertical
1150 sal_Bool bLeftToRight = sal_True;
1152 SdrOutliner* pOutl = pView->GetTextEditOutliner();
1153 if( pOutl )
1155 if( pOutl->IsVertical() )
1156 bLeftToRight = false;
1158 else
1159 bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
1161 if ( bDisableVerticalText )
1163 rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
1164 rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
1166 else
1168 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
1169 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
1172 // left-to-right or right-to-left
1174 if ( !bLeftToRight || bDisableCTLFont )
1176 // disabled if vertical
1177 rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1178 rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1180 else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SFX_ITEM_DONTCARE )
1182 rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1183 rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1185 else
1187 SvxFrameDirection eAttrDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
1188 aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue();
1189 if ( eAttrDir == FRMDIR_ENVIRONMENT )
1191 // get "environment" direction from page style
1192 if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L )
1193 eAttrDir = FRMDIR_HORI_RIGHT_TOP;
1194 else
1195 eAttrDir = FRMDIR_HORI_LEFT_TOP;
1197 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) );
1198 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) );
1202 void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq )
1204 sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
1205 if ( nType )
1207 ScDrawView* pView = pViewData->GetScDrawView();
1208 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1209 if ( pOutView )
1211 // change selected text in object
1212 pOutView->TransliterateText( nType );
1214 else
1216 //! apply to whole objects?
1221 void ScDrawTextObjectBar::GetStatePropPanelAttr(SfxItemSet &rSet)
1223 SfxWhichIter aIter( rSet );
1224 sal_uInt16 nWhich = aIter.FirstWhich();
1226 SdrView* pView = pViewData->GetScDrawView();
1228 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
1229 pView->GetAttributes(aEditAttr);
1230 //SfxItemSet aAttrs( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
1232 while ( nWhich )
1234 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1235 ? GetPool().GetSlotId(nWhich)
1236 : nWhich;
1237 switch ( nSlotId )
1239 case SID_TABLE_VERT_NONE:
1240 case SID_TABLE_VERT_CENTER:
1241 case SID_TABLE_VERT_BOTTOM:
1242 sal_Bool bContour = sal_False;
1243 SfxItemState eConState = aEditAttr.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1244 if( eConState != SFX_ITEM_DONTCARE )
1246 bContour = ( ( const SdrTextContourFrameItem& )aEditAttr.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
1248 if (bContour) break;
1250 SfxItemState eVState = aEditAttr.GetItemState( SDRATTR_TEXT_VERTADJUST );
1251 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1253 //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
1254 if(SFX_ITEM_DONTCARE != eVState)
1256 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aEditAttr.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
1257 sal_Bool bSet = nSlotId == (SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) ||
1258 (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) ||
1259 (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM);
1260 rSet.Put(SfxBoolItem(nSlotId, bSet));
1262 else
1264 rSet.Put(SfxBoolItem(nSlotId, sal_False));
1266 break;
1268 nWhich = aIter.NextWhich();
1272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */