fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / drawfunc / drtxtob.cxx
blobae5bb94123e1950abec6b7d7b5402cb2af667709
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 <svx/svdoutl.hxx>
39 #include <editeng/unolingu.hxx>
40 #include <editeng/outlobj.hxx>
41 #include <editeng/postitem.hxx>
42 #include <editeng/scripttypeitem.hxx>
43 #include <editeng/shdditem.hxx>
44 #include <svl/srchitem.hxx>
45 #include <editeng/udlnitem.hxx>
46 #include <editeng/wghtitem.hxx>
47 #include <editeng/writingmodeitem.hxx>
48 #include <sfx2/app.hxx>
49 #include <sfx2/dispatch.hxx>
50 #include <sfx2/objface.hxx>
51 #include <sfx2/objsh.hxx>
52 #include <sfx2/request.hxx>
53 #include <sfx2/viewfrm.hxx>
54 #include <svtools/cliplistener.hxx>
55 #include <svtools/transfer.hxx>
56 #include <svl/whiter.hxx>
57 #include <svl/languageoptions.hxx>
58 #include <vcl/msgbox.hxx>
60 #include <svx/svxdlg.hxx>
61 #include <svx/dialogs.hrc>
62 #include <sfx2/sidebar/EnumContext.hxx>
64 #include "sc.hrc"
65 #include "globstr.hrc"
66 #include "scmod.hxx"
67 #include "drtxtob.hxx"
68 #include "fudraw.hxx"
69 #include "viewdata.hxx"
70 #include "document.hxx"
71 #include "drawview.hxx"
72 #include "viewutil.hxx"
73 #include "scresid.hxx"
74 #include "tabvwsh.hxx"
75 #include <gridwin.hxx>
77 #define ScDrawTextObjectBar
78 #include "scslots.hxx"
80 #include <boost/scoped_ptr.hpp>
82 using namespace ::com::sun::star;
84 SFX_IMPL_INTERFACE(ScDrawTextObjectBar, SfxShell)
86 void ScDrawTextObjectBar::InitInterface_Impl()
88 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
89 RID_TEXT_TOOLBOX);
91 GetStaticInterface()->RegisterPopupMenu(ScResId(RID_POPUP_DRAWTEXT));
93 GetStaticInterface()->RegisterChildWindow(ScGetFontWorkId());
96 TYPEINIT1( ScDrawTextObjectBar, SfxShell );
98 // abschalten der nicht erwuenschten Acceleratoren:
100 void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
102 SfxWhichIter aIter(rSet);
103 sal_uInt16 nWhich = aIter.FirstWhich();
105 while (nWhich)
107 rSet.DisableItem( nWhich );
108 nWhich = aIter.NextWhich();
112 ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
113 SfxShell(pData->GetViewShell()),
114 pViewData(pData),
115 pClipEvtLstnr(NULL),
116 bPastePossible(false)
118 SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
120 // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt...
121 ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
122 SetUndoManager( pMgr );
123 if ( !pViewData->GetDocument()->IsUndoEnabled() )
125 pMgr->SetMaxUndoActionCount( 0 );
128 SetHelpId( HID_SCSHELL_DRTXTOB );
129 SetName(OUString("DrawText"));
130 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText));
133 ScDrawTextObjectBar::~ScDrawTextObjectBar()
135 if ( pClipEvtLstnr )
137 pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
139 // The listener may just now be waiting for the SolarMutex and call the link
140 // afterwards, in spite of RemoveListener. So the link has to be reset, too.
141 pClipEvtLstnr->ClearCallbackLink();
143 pClipEvtLstnr->release();
147 // Funktionen
149 void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
151 ScDrawView* pView = pViewData->GetScDrawView();
152 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
153 Outliner* pOutliner = pView->GetTextEditOutliner();
155 if (!pOutView || !pOutliner)
157 ExecuteGlobal( rReq ); // auf ganze Objekte
158 return;
161 const SfxItemSet* pReqArgs = rReq.GetArgs();
162 sal_uInt16 nSlot = rReq.GetSlot();
163 switch ( nSlot )
165 case SID_COPY:
166 pOutView->Copy();
167 break;
169 case SID_CUT:
170 pOutView->Cut();
171 break;
173 case SID_PASTE:
174 pOutView->PasteSpecial();
175 break;
177 case SID_CLIPBOARD_FORMAT_ITEMS:
179 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
180 const SfxPoolItem* pItem;
181 if ( pReqArgs &&
182 pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
183 pItem->ISA(SfxUInt32Item) )
185 nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
188 if ( nFormat != SotClipboardFormatId::NONE )
190 if (nFormat == SotClipboardFormatId::STRING)
191 pOutView->Paste();
192 else
193 pOutView->PasteSpecial();
196 break;
198 case SID_PASTE_SPECIAL:
199 ExecutePasteContents( rReq );
200 break;
202 case SID_SELECTALL:
204 sal_Int32 nCount = pOutliner->GetParagraphCount();
205 ESelection aSel( 0,0,nCount,0 );
206 pOutView->SetSelection( aSel );
208 break;
210 case SID_CHARMAP:
212 const SvxFontItem& rItem = static_cast<const SvxFontItem&>(
213 pOutView->GetAttribs().Get(EE_CHAR_FONTINFO));
215 OUString aString;
216 SvxFontItem aNewItem( EE_CHAR_FONTINFO );
218 const SfxItemSet *pArgs = rReq.GetArgs();
219 const SfxPoolItem* pItem = 0;
220 if( pArgs )
221 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
223 if ( pItem )
225 aString = static_cast<const SfxStringItem*>(pItem)->GetValue();
226 const SfxPoolItem* pFtItem = NULL;
227 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
228 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
229 if ( pFontItem )
231 OUString aFontName(pFontItem->GetValue());
232 vcl::Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
233 aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
234 aFont.GetStyleName(), aFont.GetPitch(),
235 aFont.GetCharSet(), ATTR_FONT );
237 else
238 aNewItem = rItem;
240 else
241 ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
243 if ( !aString.isEmpty() )
245 SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
246 aSet.Put( aNewItem );
247 // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
248 pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() );
249 pOutView->InsertText(aString);
252 Invalidate( SID_ATTR_CHAR_FONT );
254 break;
256 case SID_HYPERLINK_SETLINK:
257 if( pReqArgs )
259 const SfxPoolItem* pItem;
260 if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
262 const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
263 const OUString& rName = pHyper->GetName();
264 const OUString& rURL = pHyper->GetURL();
265 const OUString& rTarget = pHyper->GetTargetFrame();
266 SvxLinkInsertMode eMode = pHyper->GetInsertMode();
268 bool bDone = false;
269 if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) )
271 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
272 if (pFieldItem)
274 const SvxFieldData* pField = pFieldItem->GetField();
275 if ( pField && pField->ISA(SvxURLField) )
277 // altes Feld selektieren
279 ESelection aSel = pOutView->GetSelection();
280 aSel.Adjust();
281 aSel.nEndPara = aSel.nStartPara;
282 aSel.nEndPos = aSel.nStartPos + 1;
283 pOutView->SetSelection( aSel );
287 // neues Feld einfuegen
289 SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
290 aURLField.SetTargetFrame( rTarget );
291 SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
292 pOutView->InsertField( aURLItem );
294 // select new field
296 ESelection aSel = pOutView->GetSelection();
297 if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 )
299 // Cursor is behind the inserted field -> extend selection to the left
301 --aSel.nStartPos;
302 pOutView->SetSelection( aSel );
305 bDone = true;
308 if (!bDone)
309 ExecuteGlobal( rReq ); // normal an der View
311 // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
314 break;
316 case SID_OPEN_HYPERLINK:
318 if ( pOutView )
320 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
321 if ( pFieldItem )
323 const SvxFieldData* pField = pFieldItem->GetField();
324 if( pField && pField->ISA( SvxURLField ) )
326 const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
327 ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
332 break;
334 case SID_ENABLE_HYPHENATION:
335 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
336 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
337 pView->ScEndTextEdit(); // end text edit before switching direction
338 ExecuteGlobal( rReq );
339 // restore consistent state between shells and functions:
340 pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SfxCallMode::SLOT | SfxCallMode::RECORD);
341 break;
343 case SID_THES:
345 OUString aReplaceText;
346 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, false );
347 if (pItem2)
348 aReplaceText = pItem2->GetValue();
349 if (!aReplaceText.isEmpty())
350 ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
352 break;
354 case SID_THESAURUS:
356 pOutView->StartThesaurus();
358 break;
363 void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
365 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
366 bool bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK);
367 bool bDisableFontWork = false;
369 if (IsNoteEdit())
371 // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
372 bDisableFontWork = true;
375 if ( bDisableFontWork )
376 rSet.DisableItem( SID_FONTWORK );
377 else
378 rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
380 if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SfxItemState::UNKNOWN )
382 SvxHyperlinkItem aHLinkItem;
383 SdrView* pView = pViewData->GetScDrawView();
384 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
385 if ( pOutView )
387 bool bField = false;
388 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
389 if (pFieldItem)
391 const SvxFieldData* pField = pFieldItem->GetField();
392 if ( pField && pField->ISA(SvxURLField) )
394 const SvxURLField* pURLField = static_cast<const SvxURLField*>(pField);
395 aHLinkItem.SetName( pURLField->GetRepresentation() );
396 aHLinkItem.SetURL( pURLField->GetURL() );
397 aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
398 bField = true;
401 if (!bField)
403 // use selected text as name for urls
404 OUString sReturn = pOutView->GetSelected();
405 sal_Int32 nLen = std::min<sal_Int32>(sReturn.getLength(), 255);
406 sReturn = sReturn.copy(0, nLen);
407 aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
410 rSet.Put(aHLinkItem);
413 if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SfxItemState::UNKNOWN )
415 SdrView* pView = pViewData->GetScDrawView();
416 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
417 bool bEnable = false;
418 if ( pOutView )
420 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
421 if ( pFieldItem )
423 const SvxFieldData* pField = pFieldItem->GetField();
424 bEnable = pField && pField->ISA( SvxURLField );
427 if( !bEnable )
428 rSet.DisableItem( SID_OPEN_HYPERLINK );
431 if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SfxItemState::UNKNOWN )
432 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
433 if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SfxItemState::UNKNOWN )
434 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
435 if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SfxItemState::UNKNOWN )
436 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA );
437 if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SfxItemState::UNKNOWN )
438 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA );
440 if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SfxItemState::UNKNOWN )
442 SdrView* pView = pViewData->GetScDrawView();
443 SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
444 pView->GetAttributes( aAttrs );
445 if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
447 bool bValue = static_cast<const SfxBoolItem&>( aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
448 rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
452 if ( rSet.GetItemState( SID_THES ) != SfxItemState::UNKNOWN ||
453 rSet.GetItemState( SID_THESAURUS ) != SfxItemState::UNKNOWN )
455 SdrView * pView = pViewData->GetScDrawView();
456 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
458 OUString aStatusVal;
459 LanguageType nLang = LANGUAGE_NONE;
460 bool bIsLookUpWord = false;
461 if ( pOutView )
463 EditView& rEditView = pOutView->GetEditView();
464 bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
466 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
468 // disable thesaurus main menu and context menu entry if there is nothing to look up
469 bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
470 if (!bIsLookUpWord || !bCanDoThesaurus)
471 rSet.DisableItem( SID_THES );
472 if (!bCanDoThesaurus)
473 rSet.DisableItem( SID_THESAURUS );
477 IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper )
479 if ( pDataHelper )
481 bPastePossible = ( pDataHelper->HasFormat( SotClipboardFormatId::STRING ) || pDataHelper->HasFormat( SotClipboardFormatId::RTF ) );
483 SfxBindings& rBindings = pViewData->GetBindings();
484 rBindings.Invalidate( SID_PASTE );
485 rBindings.Invalidate( SID_PASTE_SPECIAL );
486 rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
488 return 0;
491 void ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
493 SdrView* pView = pViewData->GetScDrawView();
494 if ( !pView->GetTextEditOutlinerView() )
496 GetGlobalClipState( rSet );
497 return;
500 if ( !pClipEvtLstnr )
502 // create listener
503 pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
504 pClipEvtLstnr->acquire();
505 vcl::Window* pWin = pViewData->GetActiveWin();
506 pClipEvtLstnr->AddRemoveListener( pWin, true );
508 // get initial state
509 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
510 bPastePossible = ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) || aDataHelper.HasFormat( SotClipboardFormatId::RTF ) );
513 SfxWhichIter aIter( rSet );
514 sal_uInt16 nWhich = aIter.FirstWhich();
515 while (nWhich)
517 switch (nWhich)
519 case SID_PASTE:
520 case SID_PASTE_SPECIAL:
521 if( !bPastePossible )
522 rSet.DisableItem( nWhich );
523 break;
524 case SID_CLIPBOARD_FORMAT_ITEMS:
525 if ( bPastePossible )
527 SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
528 TransferableDataHelper aDataHelper(
529 TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
531 if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
532 aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
533 if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
534 aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
536 rSet.Put( aFormats );
538 else
539 rSet.DisableItem( nWhich );
540 break;
542 nWhich = aIter.NextWhich();
546 // Attribute
548 void ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq )
550 // Unterstreichung
552 SdrView* pView = pViewData->GetScDrawView();
554 sal_uInt16 nSlot = rReq.GetSlot();
556 SfxItemSet aSet( pView->GetDefaultAttr() );
558 SfxItemSet aViewAttr(pView->GetModel()->GetItemPool());
559 pView->GetAttributes(aViewAttr);
561 // Unterstreichung
562 FontUnderline eOld = static_cast<const SvxUnderlineItem&>( aViewAttr.
563 Get(EE_CHAR_UNDERLINE)).GetLineStyle();
564 FontUnderline eNew = eOld;
565 switch (nSlot)
567 case SID_ULINE_VAL_NONE:
568 eNew = UNDERLINE_NONE;
569 break;
570 case SID_ULINE_VAL_SINGLE:
571 eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
572 break;
573 case SID_ULINE_VAL_DOUBLE:
574 eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
575 break;
576 case SID_ULINE_VAL_DOTTED:
577 eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
578 break;
579 default:
580 break;
582 aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
584 pView->SetAttributes( aSet );
585 rReq.Done();
586 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
589 static void lcl_RemoveFields( OutlinerView& rOutView )
591 //! Outliner should have RemoveFields with a selection
593 Outliner* pOutliner = rOutView.GetOutliner();
594 if (!pOutliner) return;
596 ESelection aOldSel = rOutView.GetSelection();
597 ESelection aSel = aOldSel;
598 aSel.Adjust();
599 sal_Int32 nNewEnd = aSel.nEndPos;
601 bool bUpdate = pOutliner->GetUpdateMode();
602 bool bChanged = false;
604 //! GetPortions and GetAttribs should be const!
605 EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
607 sal_Int32 nParCount = pOutliner->GetParagraphCount();
608 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
609 if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
611 std::vector<sal_Int32> aPortions;
612 rEditEng.GetPortions( nPar, aPortions );
614 for ( size_t nPos = aPortions.size(); nPos; )
616 --nPos;
617 sal_Int32 nEnd = aPortions[ nPos ];
618 sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
619 // fields are single characters
620 if ( nEnd == nStart+1 &&
621 ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
622 ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) )
624 ESelection aFieldSel( nPar, nStart, nPar, nEnd );
625 SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
626 if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SfxItemState::SET )
628 if (!bChanged)
630 if (bUpdate)
631 pOutliner->SetUpdateMode( false );
632 OUString aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
633 pOutliner->GetUndoManager().EnterListAction( aName, aName );
634 bChanged = true;
637 OUString aFieldText = rEditEng.GetText( aFieldSel );
638 pOutliner->QuickInsertText( aFieldText, aFieldSel );
639 if ( nPar == aSel.nEndPara )
641 nNewEnd = nNewEnd + aFieldText.getLength();
642 --nNewEnd;
649 if (bUpdate && bChanged)
651 pOutliner->GetUndoManager().LeaveListAction();
652 pOutliner->SetUpdateMode( true );
655 if ( aOldSel.IsEqual( aSel ) ) // aSel is adjusted
656 aOldSel.nEndPos = nNewEnd;
657 else
658 aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards
659 rOutView.SetSelection( aOldSel );
662 void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
664 SdrView* pView = pViewData->GetScDrawView();
665 const SfxItemSet* pArgs = rReq.GetArgs();
666 sal_uInt16 nSlot = rReq.GetSlot();
668 SfxItemSet aEditAttr( pView->GetModel()->GetItemPool() );
669 pView->GetAttributes( aEditAttr );
670 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
672 bool bSet = true;
673 switch ( nSlot )
675 case SID_ALIGNLEFT:
676 case SID_ALIGN_ANY_LEFT:
677 case SID_ATTR_PARA_ADJUST_LEFT:
678 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
679 break;
681 case SID_ALIGNCENTERHOR:
682 case SID_ALIGN_ANY_HCENTER:
683 case SID_ATTR_PARA_ADJUST_CENTER:
684 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
685 break;
687 case SID_ALIGNRIGHT:
688 case SID_ALIGN_ANY_RIGHT:
689 case SID_ATTR_PARA_ADJUST_RIGHT:
690 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
691 break;
693 case SID_ALIGNBLOCK:
694 case SID_ALIGN_ANY_JUSTIFIED:
695 case SID_ATTR_PARA_ADJUST_BLOCK:
696 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
697 break;
699 case SID_ATTR_PARA_LINESPACE_10:
701 SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL );
702 aItem.SetPropLineSpace( 100 );
703 aNewAttr.Put( aItem );
705 break;
707 case SID_ATTR_PARA_LINESPACE_15:
709 SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL );
710 aItem.SetPropLineSpace( 150 );
711 aNewAttr.Put( aItem );
713 break;
715 case SID_ATTR_PARA_LINESPACE_20:
717 SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
718 aItem.SetPropLineSpace( 200 );
719 aNewAttr.Put( aItem );
721 break;
723 case SID_SET_SUPER_SCRIPT:
725 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
726 SvxEscapement eEsc = (SvxEscapement) static_cast<const SvxEscapementItem&>(
727 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
729 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
730 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
731 else
732 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
733 aNewAttr.Put( aItem );
735 break;
737 case SID_SET_SUB_SCRIPT:
739 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
740 SvxEscapement eEsc = (SvxEscapement) static_cast<const SvxEscapementItem&>(
741 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
743 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
744 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
745 else
746 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
747 aNewAttr.Put( aItem );
749 break;
751 case SID_TABLE_VERT_NONE:
752 case SID_TABLE_VERT_CENTER:
753 case SID_TABLE_VERT_BOTTOM:
755 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
756 if (nSlot == SID_TABLE_VERT_CENTER)
757 eTVA = SDRTEXTVERTADJUST_CENTER;
758 else if (nSlot == SID_TABLE_VERT_BOTTOM)
759 eTVA = SDRTEXTVERTADJUST_BOTTOM;
760 aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
762 break;
764 case SID_PARASPACE_INCREASE:
765 case SID_PARASPACE_DECREASE:
767 SvxULSpaceItem aULSpace(
768 static_cast< const SvxULSpaceItem& >( aEditAttr.Get( EE_PARA_ULSPACE ) ) );
769 sal_uInt16 nUpper = aULSpace.GetUpper();
770 sal_uInt16 nLower = aULSpace.GetLower();
772 if ( nSlot == SID_PARASPACE_INCREASE )
774 nUpper += 100;
775 nLower += 100;
777 else
779 nUpper = std::max< sal_Int16 >( nUpper - 100, 0 );
780 nLower = std::max< sal_Int16 >( nLower - 100, 0 );
783 aULSpace.SetUpper( nUpper );
784 aULSpace.SetLower( nLower );
785 aNewAttr.Put( aULSpace );
787 break;
789 default:
790 bSet = false;
793 bool bDone = true;
794 bool bArgsInReq = ( pArgs != NULL );
796 if ( !bArgsInReq )
798 switch ( nSlot )
800 case SID_TEXT_STANDARD: // Harte Textattributierung loeschen
802 OutlinerView* pOutView = pView->IsTextEdit() ?
803 pView->GetTextEditOutlinerView() : NULL;
804 if ( pOutView )
805 pOutView->Paint( Rectangle() );
807 SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END );
808 pView->SetAttributes( aEmptyAttr, true );
810 if ( pOutView )
812 lcl_RemoveFields( *pOutView );
813 pOutView->ShowCursor();
816 rReq.Done( aEmptyAttr );
817 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
818 bDone = false; // bereits hier passiert
820 break;
822 case SID_CHAR_DLG_EFFECT:
823 case SID_CHAR_DLG: // Dialog-Button
824 case SID_ATTR_CHAR_FONT: // Controller nicht angezeigt
825 case SID_ATTR_CHAR_FONTHEIGHT:
826 bDone = ExecuteCharDlg( aEditAttr, aNewAttr , nSlot);
827 break;
829 case SID_PARA_DLG:
830 bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
831 break;
833 case SID_ATTR_CHAR_WEIGHT:
834 aNewAttr.Put( static_cast<const SvxWeightItem&>(aEditAttr.Get( EE_CHAR_WEIGHT )) );
835 break;
837 case SID_ATTR_CHAR_POSTURE:
838 aNewAttr.Put( static_cast<const SvxPostureItem&>(aEditAttr.Get( EE_CHAR_ITALIC )) );
839 break;
841 case SID_ATTR_CHAR_UNDERLINE:
842 aNewAttr.Put( static_cast<const SvxUnderlineItem&>(aEditAttr.Get( EE_CHAR_UNDERLINE )) );
843 break;
845 case SID_ATTR_CHAR_OVERLINE:
846 aNewAttr.Put( static_cast<const SvxOverlineItem&>(aEditAttr.Get( EE_CHAR_OVERLINE )) );
847 break;
849 case SID_ATTR_CHAR_CONTOUR:
850 aNewAttr.Put( static_cast<const SvxContourItem&>(aEditAttr.Get( EE_CHAR_OUTLINE )) );
851 break;
853 case SID_ATTR_CHAR_SHADOWED:
854 aNewAttr.Put( static_cast<const SvxShadowedItem&>(aEditAttr.Get( EE_CHAR_SHADOW )) );
855 break;
857 case SID_ATTR_CHAR_STRIKEOUT:
858 aNewAttr.Put( static_cast<const SvxCrossedOutItem&>(aEditAttr.Get( EE_CHAR_STRIKEOUT )) );
859 break;
861 case SID_DRAWTEXT_ATTR_DLG:
863 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
864 boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView ));
866 bDone = ( RET_OK == pDlg->Execute() );
868 if ( bDone )
869 aNewAttr.Put( *pDlg->GetOutputItemSet() );
871 pDlg.reset();
873 SfxBindings& rBindings = pViewData->GetBindings();
874 rBindings.Invalidate( SID_TABLE_VERT_NONE );
875 rBindings.Invalidate( SID_TABLE_VERT_CENTER );
876 rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
878 break;
882 if ( bSet || bDone )
884 rReq.Done( aNewAttr );
885 pArgs = rReq.GetArgs();
888 if ( pArgs )
890 if ( bArgsInReq &&
891 ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
892 nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
894 // font items from toolbox controller have to be applied for the right script type
896 // #i78017 establish the same behaviour as in Writer
897 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
898 if (nSlot == SID_ATTR_CHAR_FONT)
899 nScript = pView->GetScriptType();
901 SfxItemPool& rPool = GetPool();
902 SvxScriptSetItem aSetItem( nSlot, rPool );
903 sal_uInt16 nWhich = rPool.GetWhich( nSlot );
904 aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
906 pView->SetAttributes( aSetItem.GetItemSet() );
908 else if( nSlot == SID_ATTR_PARA_LRSPACE )
910 sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
911 const SvxLRSpaceItem& rItem = static_cast<const SvxLRSpaceItem&>(
912 pArgs->Get( nId ));
913 SfxItemSet aAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
914 nId = EE_PARA_LRSPACE;
915 SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
916 rItem.GetRight(), rItem.GetTextLeft(),
917 rItem.GetTextFirstLineOfst(), nId );
918 aAttr.Put( aLRSpaceItem );
919 pView->SetAttributes( aAttr );
921 else if( nSlot == SID_ATTR_PARA_LINESPACE )
923 SvxLineSpacingItem aLineSpaceItem = static_cast<const SvxLineSpacingItem&>(pArgs->Get(
924 GetPool().GetWhich(nSlot)));
925 SfxItemSet aAttr( GetPool(), EE_PARA_SBL, EE_PARA_SBL );
926 aAttr.Put( aLineSpaceItem );
927 pView->SetAttributes( aAttr );
929 else if( nSlot == SID_ATTR_PARA_ULSPACE )
931 SvxULSpaceItem aULSpaceItem = static_cast<const SvxULSpaceItem&>(pArgs->Get(
932 GetPool().GetWhich(nSlot)));
933 SfxItemSet aAttr( GetPool(), EE_PARA_ULSPACE, EE_PARA_ULSPACE );
934 aULSpaceItem.SetWhich(EE_PARA_ULSPACE);
935 aAttr.Put( aULSpaceItem );
936 pView->SetAttributes( aAttr );
938 else
940 // use args directly
941 pView->SetAttributes( *pArgs );
943 pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
947 void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet )
949 if ( IsNoteEdit() )
951 // issue 21255 - Notes now support rich text formatting.
954 SvtLanguageOptions aLangOpt;
955 bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
956 bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
958 SdrView* pView = pViewData->GetScDrawView();
959 SfxItemSet aAttrSet(pView->GetModel()->GetItemPool());
960 pView->GetAttributes(aAttrSet);
962 // direkte Attribute
964 rDestSet.Put( aAttrSet );
966 // choose font info according to selection script type
968 SvtScriptType nScript = pView->GetScriptType();
970 // #i55929# input-language-dependent script type (depends on input language if nothing selected)
971 SvtScriptType nInputScript = nScript;
972 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
973 if (pOutView && !pOutView->GetSelection().HasRange())
975 LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
976 if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
977 nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
980 // #i55929# according to spec, nInputScript is used for font and font height only
981 if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SfxItemState::UNKNOWN )
982 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
983 if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SfxItemState::UNKNOWN )
984 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
985 if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SfxItemState::UNKNOWN )
986 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
987 if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SfxItemState::UNKNOWN )
988 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
989 // Ausrichtung
991 SvxAdjust eAdj = static_cast<const SvxAdjustItem&>(aAttrSet.Get(EE_PARA_JUST)).GetAdjust();
992 switch( eAdj )
994 case SVX_ADJUST_LEFT:
996 rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, true ) );
997 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
999 break;
1000 case SVX_ADJUST_CENTER:
1002 rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, true ) );
1003 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
1005 break;
1006 case SVX_ADJUST_RIGHT:
1008 rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, true ) );
1009 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
1011 break;
1012 case SVX_ADJUST_BLOCK:
1014 rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, true ) );
1015 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
1017 break;
1018 default:
1020 // added to avoid warnings
1023 // pseudo slots for Format menu
1024 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SVX_ADJUST_LEFT ) );
1025 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SVX_ADJUST_CENTER ) );
1026 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SVX_ADJUST_RIGHT ) );
1027 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) );
1029 SvxLRSpaceItem aLR = static_cast<const SvxLRSpaceItem&>(aAttrSet.Get( EE_PARA_LRSPACE ));
1030 aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
1031 rDestSet.Put(aLR);
1032 Invalidate( SID_ATTR_PARA_LRSPACE );
1033 SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
1034 if ( eState == SfxItemState::DONTCARE )
1035 rDestSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
1036 //xuxu for Line Space
1037 SvxLineSpacingItem aLineSP = static_cast<const SvxLineSpacingItem&>(aAttrSet.
1038 Get( EE_PARA_SBL ));
1039 aLineSP.SetWhich(SID_ATTR_PARA_LINESPACE);
1040 rDestSet.Put(aLineSP);
1041 Invalidate(SID_ATTR_PARA_LINESPACE);
1042 eState = aAttrSet.GetItemState( EE_PARA_SBL );
1043 if ( eState == SfxItemState::DONTCARE )
1044 rDestSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
1045 //xuxu for UL Space
1046 SvxULSpaceItem aULSP = static_cast<const SvxULSpaceItem&>(aAttrSet.
1047 Get( EE_PARA_ULSPACE ));
1048 aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
1049 rDestSet.Put(aULSP);
1050 Invalidate(SID_ATTR_PARA_ULSPACE);
1051 Invalidate(SID_PARASPACE_INCREASE);
1052 Invalidate(SID_PARASPACE_DECREASE);
1053 eState = aAttrSet.GetItemState( EE_PARA_ULSPACE );
1054 if( eState >= SfxItemState::DEFAULT )
1056 if ( !aULSP.GetUpper() && !aULSP.GetLower() )
1057 rDestSet.DisableItem( SID_PARASPACE_DECREASE );
1059 else
1061 rDestSet.DisableItem( SID_PARASPACE_INCREASE );
1062 rDestSet.DisableItem( SID_PARASPACE_DECREASE );
1063 rDestSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
1066 // Zeilenabstand
1068 sal_uInt16 nLineSpace = (sal_uInt16)
1069 static_cast<const SvxLineSpacingItem&>(aAttrSet.
1070 Get( EE_PARA_SBL )).GetPropLineSpace();
1071 switch( nLineSpace )
1073 case 100:
1074 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, true ) );
1075 break;
1076 case 150:
1077 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, true ) );
1078 break;
1079 case 200:
1080 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, true ) );
1081 break;
1084 // hoch-/tiefgestellt
1086 SvxEscapement eEsc = (SvxEscapement) static_cast<const SvxEscapementItem&>(
1087 aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1088 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
1089 rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, true ) );
1090 else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
1091 rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, true ) );
1093 // Unterstreichung
1095 eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, true );
1096 if ( eState == SfxItemState::DONTCARE )
1098 rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
1099 rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1100 rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1101 rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1103 else
1105 FontUnderline eUnderline = static_cast<const SvxUnderlineItem&>(
1106 aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
1107 sal_uInt16 nId = SID_ULINE_VAL_NONE;
1108 switch (eUnderline)
1110 case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
1111 case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
1112 case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
1113 default:
1114 break;
1116 rDestSet.Put( SfxBoolItem( nId, true ) );
1119 // horizontal / vertical
1121 bool bLeftToRight = true;
1123 SdrOutliner* pOutl = pView->GetTextEditOutliner();
1124 if( pOutl )
1126 if( pOutl->IsVertical() )
1127 bLeftToRight = false;
1129 else
1130 bLeftToRight = static_cast<const SvxWritingModeItem&>( aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
1132 if ( bDisableVerticalText )
1134 rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
1135 rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
1137 else
1139 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
1140 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
1143 // left-to-right or right-to-left
1145 if ( !bLeftToRight || bDisableCTLFont )
1147 // disabled if vertical
1148 rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1149 rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1151 else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SfxItemState::DONTCARE )
1153 rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1154 rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1156 else
1158 SvxFrameDirection eAttrDir = (SvxFrameDirection)static_cast<const SvxFrameDirectionItem&>(
1159 aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue();
1160 if ( eAttrDir == FRMDIR_ENVIRONMENT )
1162 // get "environment" direction from page style
1163 if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L )
1164 eAttrDir = FRMDIR_HORI_RIGHT_TOP;
1165 else
1166 eAttrDir = FRMDIR_HORI_LEFT_TOP;
1168 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) );
1169 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) );
1173 void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq )
1175 sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
1176 if ( nType )
1178 ScDrawView* pView = pViewData->GetScDrawView();
1179 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1180 if ( pOutView )
1182 // change selected text in object
1183 pOutView->TransliterateText( nType );
1185 else
1187 //! apply to whole objects?
1192 void ScDrawTextObjectBar::GetStatePropPanelAttr(SfxItemSet &rSet)
1194 SfxWhichIter aIter( rSet );
1195 sal_uInt16 nWhich = aIter.FirstWhich();
1197 SdrView* pView = pViewData->GetScDrawView();
1199 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
1200 pView->GetAttributes(aEditAttr);
1201 //SfxItemSet aAttrs( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
1203 while ( nWhich )
1205 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1206 ? GetPool().GetSlotId(nWhich)
1207 : nWhich;
1208 switch ( nSlotId )
1210 case SID_TABLE_VERT_NONE:
1211 case SID_TABLE_VERT_CENTER:
1212 case SID_TABLE_VERT_BOTTOM:
1213 bool bContour = false;
1214 SfxItemState eConState = aEditAttr.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1215 if( eConState != SfxItemState::DONTCARE )
1217 bContour = static_cast<const SdrOnOffItem&>( aEditAttr.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
1219 if (bContour) break;
1221 SfxItemState eVState = aEditAttr.GetItemState( SDRATTR_TEXT_VERTADJUST );
1222 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1224 //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState)
1225 if(SfxItemState::DONTCARE != eVState)
1227 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)static_cast<const SdrTextVertAdjustItem&>(aEditAttr.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
1228 bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) ||
1229 (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) ||
1230 (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM);
1231 rSet.Put(SfxBoolItem(nSlotId, bSet));
1233 else
1235 rSet.Put(SfxBoolItem(nSlotId, false));
1237 break;
1239 nWhich = aIter.NextWhich();
1243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */