tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / drawfunc / drtxtob.cxx
blobd5d00a2f04bd3014ee885ff3b5a61d0bb45dfe6f
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 <comphelper/string.hxx>
21 #include <scitems.hxx>
23 #include <i18nutil/transliteration.hxx>
24 #include <editeng/adjustitem.hxx>
25 #include <svx/clipfmtitem.hxx>
26 #include <editeng/colritem.hxx>
27 #include <editeng/contouritem.hxx>
28 #include <editeng/crossedoutitem.hxx>
29 #include <editeng/eeitem.hxx>
30 #include <editeng/editeng.hxx>
31 #include <editeng/editview.hxx>
32 #include <editeng/escapementitem.hxx>
33 #include <editeng/flditem.hxx>
34 #include <editeng/flstitem.hxx>
35 #include <editeng/fontitem.hxx>
36 #include <editeng/frmdiritem.hxx>
37 #include <editeng/lrspitem.hxx>
38 #include <editeng/lspcitem.hxx>
39 #include <editeng/ulspitem.hxx>
40 #include <editeng/urlfieldhelper.hxx>
41 #include <editeng/editund2.hxx>
42 #include <svx/hlnkitem.hxx>
43 #include <svx/svdoutl.hxx>
44 #include <svx/sdooitm.hxx>
45 #include <editeng/postitem.hxx>
46 #include <editeng/scripttypeitem.hxx>
47 #include <editeng/shdditem.hxx>
48 #include <editeng/udlnitem.hxx>
49 #include <editeng/wghtitem.hxx>
50 #include <editeng/writingmodeitem.hxx>
51 #include <sfx2/dispatch.hxx>
52 #include <sfx2/namedcolor.hxx>
53 #include <sfx2/objface.hxx>
54 #include <sfx2/objsh.hxx>
55 #include <sfx2/request.hxx>
56 #include <sfx2/viewfrm.hxx>
57 #include <svtools/cliplistener.hxx>
58 #include <vcl/transfer.hxx>
59 #include <svl/stritem.hxx>
60 #include <svl/whiter.hxx>
61 #include <svl/languageoptions.hxx>
62 #include <svl/cjkoptions.hxx>
63 #include <svl/ctloptions.hxx>
65 #include <svx/svxdlg.hxx>
66 #include <vcl/EnumContext.hxx>
67 #include <vcl/unohelp2.hxx>
69 #include <sc.hrc>
70 #include <globstr.hrc>
71 #include <scresid.hxx>
72 #include <scmod.hxx>
73 #include <drtxtob.hxx>
74 #include <viewdata.hxx>
75 #include <document.hxx>
76 #include <drawview.hxx>
77 #include <viewutil.hxx>
78 #include <tabvwsh.hxx>
79 #include <gridwin.hxx>
81 #define ShellClass_ScDrawTextObjectBar
82 #include <scslots.hxx>
84 using namespace ::com::sun::star;
86 SFX_IMPL_INTERFACE(ScDrawTextObjectBar, SfxShell)
88 void ScDrawTextObjectBar::InitInterface_Impl()
90 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT,
91 SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
92 ToolbarId::Text_Toolbox_Sc);
94 GetStaticInterface()->RegisterPopupMenu(u"drawtext"_ustr);
96 GetStaticInterface()->RegisterChildWindow(ScGetFontWorkId());
100 // disable not wanted accelerators
102 void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
104 SfxWhichIter aIter(rSet);
105 sal_uInt16 nWhich = aIter.FirstWhich();
107 while (nWhich)
109 rSet.DisableItem( nWhich );
110 nWhich = aIter.NextWhich();
114 ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData& rData) :
115 SfxShell(rData.GetViewShell()),
116 mrViewData(rData),
117 bPastePossible(false)
119 SetPool( mrViewData.GetScDrawView()->GetDefaultAttr().GetPool() );
121 // At the switching-over the UndoManager is changed to edit mode
122 SfxUndoManager* pMgr = mrViewData.GetSfxDocShell()->GetUndoManager();
123 SetUndoManager( pMgr );
124 if ( !mrViewData.GetDocument().IsUndoEnabled() )
126 pMgr->SetMaxUndoActionCount( 0 );
129 SetName(u"DrawText"_ustr);
130 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::DrawText));
133 ScDrawTextObjectBar::~ScDrawTextObjectBar()
135 if ( mxClipEvtLstnr.is() )
137 mxClipEvtLstnr->RemoveListener( mrViewData.GetActiveWin() );
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 mxClipEvtLstnr->ClearCallbackLink();
145 // Functions
147 void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
149 ScDrawView* pView = mrViewData.GetScDrawView();
150 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
151 Outliner* pOutliner = pView->GetTextEditOutliner();
153 if (!pOutView || !pOutliner)
155 ExecuteGlobal( rReq ); // on whole objects
156 return;
159 const SfxItemSet* pReqArgs = rReq.GetArgs();
160 sal_uInt16 nSlot = rReq.GetSlot();
161 switch ( nSlot )
163 case SID_COPY:
164 pOutView->Copy();
165 break;
167 case SID_CUT:
168 pOutView->Cut();
169 break;
171 case SID_PASTE:
172 pOutView->PasteSpecial();
173 break;
175 case SID_CLIPBOARD_FORMAT_ITEMS:
177 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
178 const SfxPoolItem* pItem;
179 if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
180 if (auto pIntItem = dynamic_cast<const SfxUInt32Item*>( pItem))
181 nFormat = static_cast<SotClipboardFormatId>(pIntItem->GetValue());
183 if ( nFormat != SotClipboardFormatId::NONE )
185 if (nFormat == SotClipboardFormatId::STRING)
186 pOutView->Paste();
187 else
188 pOutView->PasteSpecial(nFormat);
191 break;
193 case SID_PASTE_SPECIAL:
194 ExecutePasteContents( rReq );
195 break;
197 case SID_PASTE_UNFORMATTED:
198 pOutView->Paste();
199 break;
201 case SID_SELECTALL:
203 sal_Int32 nCount = pOutliner->GetParagraphCount();
204 ESelection aSel( 0,0,nCount,0 );
205 pOutView->SetSelection( aSel );
207 break;
209 case SID_CHARMAP:
211 auto const attribs = pOutView->GetAttribs();
212 const SvxFontItem& rItem = attribs.Get(EE_CHAR_FONTINFO);
214 OUString aString;
215 std::shared_ptr<SvxFontItem> aNewItem(std::make_shared<SvxFontItem>(EE_CHAR_FONTINFO));
217 const SfxItemSet *pArgs = rReq.GetArgs();
218 const SfxPoolItem* pItem = nullptr;
219 if( pArgs )
220 pArgs->GetItemState(SID_CHARMAP, false, &pItem);
222 if ( pItem )
224 aString = static_cast<const SfxStringItem*>(pItem)->GetValue();
225 const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false);
226 if ( pFontItem )
228 const OUString& aFontName(pFontItem->GetValue());
229 vcl::Font aFont(aFontName, Size(1,1)); // Size only because of CTOR
230 aNewItem = std::make_shared<SvxFontItem>(
231 aFont.GetFamilyType(), aFont.GetFamilyName(),
232 aFont.GetStyleName(), aFont.GetPitch(),
233 aFont.GetCharSet(), ATTR_FONT);
235 else
237 aNewItem.reset(rItem.Clone());
240 else
241 ScViewUtil::ExecuteCharMap(rItem, *mrViewData.GetViewShell());
243 if ( !aString.isEmpty() )
245 SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
246 // tdf#125054 set and force to needed WhichID
247 aSet.PutAsTargetWhich( *aNewItem, EE_CHAR_FONTINFO );
249 // If nothing is selected, then SetAttribs of the View selects a word
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 if ( const SvxHyperlinkItem* pHyper = pReqArgs->GetItemIfSet( SID_HYPERLINK_SETLINK) )
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 (eMode == HLINK_DEFAULT || eMode == HLINK_FIELD)
271 pOutView->SelectFieldAtCursor();
273 // insert new field
274 SvxURLField aURLField( rURL, rName, SvxURLFormat::Repr );
275 aURLField.SetTargetFrame( rTarget );
276 SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
277 pOutView->InsertField( aURLItem );
279 bDone = true;
282 if (!bDone)
283 ExecuteGlobal( rReq ); // normal at View
285 // If "text" is received by InsertURL of ViewShell, then the DrawShell is turned off !!!
288 break;
290 case SID_OPEN_HYPERLINK:
292 const SvxFieldItem* pFieldItem
293 = pOutView->GetFieldAtSelection(/*AlsoCheckBeforeCursor=*/true);
294 const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
295 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
297 ScGlobal::OpenURL(pURLField->GetURL(), pURLField->GetTargetFrame(), true);
300 break;
302 case SID_EDIT_HYPERLINK:
304 // Ensure the field is selected first
305 pOutView->SelectFieldAtCursor();
306 mrViewData.GetViewShell()->GetViewFrame().GetDispatcher()->Execute(SID_HYPERLINK_DIALOG);
308 break;
310 case SID_COPY_HYPERLINK_LOCATION:
312 const SvxFieldItem* pFieldItem
313 = pOutView->GetFieldAtSelection(/*AlsoCheckBeforeCursor=*/true);
314 const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
315 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
317 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
318 = pOutView->GetWindow()->GetClipboard();
319 vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
322 break;
324 case SID_REMOVE_HYPERLINK:
326 URLFieldHelper::RemoveURLField(pOutView->GetEditView());
328 break;
330 case SID_ENABLE_HYPHENATION:
331 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
332 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
333 pView->ScEndTextEdit(); // end text edit before switching direction
334 ExecuteGlobal( rReq );
335 // restore consistent state between shells and functions:
336 mrViewData.GetDispatcher().Execute(SID_OBJECT_SELECT, SfxCallMode::SLOT | SfxCallMode::RECORD);
337 break;
339 case SID_THES:
341 OUString aReplaceText;
342 const SfxStringItem* pItem2 = rReq.GetArg(FN_PARAM_THES_WORD_REPLACE);
343 if (pItem2)
344 aReplaceText = pItem2->GetValue();
345 if (!aReplaceText.isEmpty())
346 ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
348 break;
350 case SID_THESAURUS:
352 pOutView->StartThesaurus(rReq.GetFrameWeld());
354 break;
358 void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
360 SfxViewFrame& rViewFrm = mrViewData.GetViewShell()->GetViewFrame();
361 bool bHasFontWork = rViewFrm.HasChildWindow(SID_FONTWORK);
362 bool bDisableFontWork = false;
364 if (IsNoteEdit())
366 // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
367 bDisableFontWork = true;
370 if ( bDisableFontWork )
371 rSet.DisableItem( SID_FONTWORK );
372 else
373 rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
375 if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SfxItemState::UNKNOWN )
377 SvxHyperlinkItem aHLinkItem;
378 SdrView* pView = mrViewData.GetScDrawView();
379 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
380 if ( pOutView )
382 bool bField = false;
383 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
384 const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
385 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
387 aHLinkItem.SetName( pURLField->GetRepresentation() );
388 aHLinkItem.SetURL( pURLField->GetURL() );
389 aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
390 bField = true;
393 if (!bField)
395 // use selected text as name for urls
396 OUString sReturn = pOutView->GetSelected();
397 sal_Int32 nLen = std::min<sal_Int32>(sReturn.getLength(), 255);
398 sReturn = sReturn.copy(0, nLen);
399 aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
402 rSet.Put(aHLinkItem);
405 if (rSet.GetItemState(SID_OPEN_HYPERLINK) != SfxItemState::UNKNOWN
406 || rSet.GetItemState(SID_EDIT_HYPERLINK) != SfxItemState::UNKNOWN
407 || rSet.GetItemState(SID_COPY_HYPERLINK_LOCATION) != SfxItemState::UNKNOWN
408 || rSet.GetItemState(SID_REMOVE_HYPERLINK) != SfxItemState::UNKNOWN)
410 OutlinerView* pOutView = mrViewData.GetScDrawView()->GetTextEditOutlinerView();
411 if (!URLFieldHelper::IsCursorAtURLField(pOutView, /*AlsoCheckBeforeCursor=*/true))
413 rSet.DisableItem( SID_OPEN_HYPERLINK );
414 rSet.DisableItem( SID_EDIT_HYPERLINK );
415 rSet.DisableItem( SID_COPY_HYPERLINK_LOCATION );
416 rSet.DisableItem( SID_REMOVE_HYPERLINK );
420 if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SfxItemState::UNKNOWN )
421 ScViewUtil::HideDisabledSlot( rSet, rViewFrm.GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
422 if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SfxItemState::UNKNOWN )
423 ScViewUtil::HideDisabledSlot( rSet, rViewFrm.GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
424 if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SfxItemState::UNKNOWN )
425 ScViewUtil::HideDisabledSlot( rSet, rViewFrm.GetBindings(), SID_TRANSLITERATE_HIRAGANA );
426 if( rSet.GetItemState( SID_TRANSLITERATE_KATAKANA ) != SfxItemState::UNKNOWN )
427 ScViewUtil::HideDisabledSlot( rSet, rViewFrm.GetBindings(), SID_TRANSLITERATE_KATAKANA );
429 if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SfxItemState::UNKNOWN )
431 SdrView* pView = mrViewData.GetScDrawView();
432 SfxItemSet aAttrs(pView->GetModel().GetItemPool());
433 pView->GetAttributes( aAttrs );
434 if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
436 bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue();
437 rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
441 if ( rSet.GetItemState( SID_THES ) != SfxItemState::UNKNOWN ||
442 rSet.GetItemState( SID_THESAURUS ) != SfxItemState::UNKNOWN )
444 SdrView * pView = mrViewData.GetScDrawView();
445 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
447 OUString aStatusVal;
448 LanguageType nLang = LANGUAGE_NONE;
449 bool bIsLookUpWord = false;
450 if ( pOutView )
452 EditView& rEditView = pOutView->GetEditView();
453 bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
455 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
457 // disable thesaurus main menu and context menu entry if there is nothing to look up
458 bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
459 if (!bIsLookUpWord || !bCanDoThesaurus)
460 rSet.DisableItem( SID_THES );
461 if (!bCanDoThesaurus)
462 rSet.DisableItem( SID_THESAURUS );
465 if (GetObjectShell()->isContentExtractionLocked())
467 rSet.DisableItem(SID_COPY);
468 rSet.DisableItem(SID_CUT);
472 IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
474 bPastePossible = ( pDataHelper->HasFormat( SotClipboardFormatId::STRING ) || pDataHelper->HasFormat( SotClipboardFormatId::RTF )
475 || pDataHelper->HasFormat( SotClipboardFormatId::RICHTEXT ) );
477 SfxBindings& rBindings = mrViewData.GetBindings();
478 rBindings.Invalidate( SID_PASTE );
479 rBindings.Invalidate( SID_PASTE_SPECIAL );
480 rBindings.Invalidate( SID_PASTE_UNFORMATTED );
481 rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
484 void ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
486 SdrView* pView = mrViewData.GetScDrawView();
487 if ( !pView->GetTextEditOutlinerView() )
489 GetGlobalClipState( rSet );
490 return;
493 if ( !mxClipEvtLstnr.is() )
495 // create listener
496 mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
497 vcl::Window* pWin = mrViewData.GetActiveWin();
498 mxClipEvtLstnr->AddListener( pWin );
500 // get initial state
501 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mrViewData.GetActiveWin() ) );
502 bPastePossible = ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) || aDataHelper.HasFormat( SotClipboardFormatId::RTF )
503 || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) );
506 SfxWhichIter aIter( rSet );
507 sal_uInt16 nWhich = aIter.FirstWhich();
508 while (nWhich)
510 switch (nWhich)
512 case SID_PASTE:
513 case SID_PASTE_SPECIAL:
514 case SID_PASTE_UNFORMATTED:
515 if( !bPastePossible )
516 rSet.DisableItem( nWhich );
517 break;
518 case SID_CLIPBOARD_FORMAT_ITEMS:
519 if ( bPastePossible )
521 SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
522 TransferableDataHelper aDataHelper(
523 TransferableDataHelper::CreateFromSystemClipboard( mrViewData.GetActiveWin() ) );
525 if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
526 aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
527 if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
528 aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
529 if ( aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
530 aFormats.AddClipbrdFormat( SotClipboardFormatId::RICHTEXT );
531 if (aDataHelper.HasFormat(SotClipboardFormatId::HTML_SIMPLE))
532 aFormats.AddClipbrdFormat(SotClipboardFormatId::HTML_SIMPLE);
534 rSet.Put( aFormats );
536 else
537 rSet.DisableItem( nWhich );
538 break;
540 nWhich = aIter.NextWhich();
544 // Attributes
546 void ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq )
548 // Underline
550 SdrView* pView = mrViewData.GetScDrawView();
552 sal_uInt16 nSlot = rReq.GetSlot();
554 SfxItemSet aSet( pView->GetDefaultAttr() );
556 SfxItemSet aViewAttr(pView->GetModel().GetItemPool());
557 pView->GetAttributes(aViewAttr);
559 // Underline
560 FontLineStyle eOld = aViewAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
561 FontLineStyle eNew = eOld;
562 switch (nSlot)
564 case SID_ULINE_VAL_NONE:
565 eNew = LINESTYLE_NONE;
566 break;
567 case SID_ULINE_VAL_SINGLE:
568 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
569 break;
570 case SID_ULINE_VAL_DOUBLE:
571 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
572 break;
573 case SID_ULINE_VAL_DOTTED:
574 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
575 break;
576 default:
577 break;
579 aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
581 pView->SetAttributes( aSet );
582 rReq.Done();
583 mrViewData.GetScDrawView()->InvalidateDrawTextAttrs();
586 static void lcl_RemoveFields( OutlinerView& rOutView )
588 //! Outliner should have RemoveFields with a selection
590 Outliner* pOutliner = rOutView.GetOutliner();
591 if (!pOutliner) return;
593 ESelection aOldSel = rOutView.GetSelection();
594 ESelection aSel = aOldSel;
595 aSel.Adjust();
596 sal_Int32 nNewEnd = aSel.end.nIndex;
598 bool bUpdate = pOutliner->IsUpdateLayout();
599 bool bChanged = false;
601 //! GetPortions and GetAttribs should be const!
602 EditEngine& rEditEng = const_cast<EditEngine&>(pOutliner->GetEditEngine());
604 sal_Int32 nParCount = pOutliner->GetParagraphCount();
605 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
606 if (nPar >= aSel.start.nPara && nPar <= aSel.end.nPara)
608 std::vector<sal_Int32> aPortions;
609 rEditEng.GetPortions( nPar, aPortions );
611 for ( size_t nPos = aPortions.size(); nPos; )
613 --nPos;
614 sal_Int32 nEnd = aPortions[ nPos ];
615 sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
616 // fields are single characters
617 if ( nEnd == nStart+1 &&
618 ( nPar > aSel.start.nPara || nStart >= aSel.start.nIndex ) &&
619 ( nPar < aSel.end.nPara || nEnd <= aSel.end.nIndex ) )
621 ESelection aFieldSel( nPar, nStart, nPar, nEnd );
622 SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
623 if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SfxItemState::SET )
625 if (!bChanged)
627 if (bUpdate)
628 pOutliner->SetUpdateLayout( false );
629 OUString aName = ScResId( STR_UNDO_DELETECONTENTS );
630 ViewShellId nViewShellId(-1);
631 if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
632 nViewShellId = pViewSh->GetViewShellId();
633 pOutliner->GetUndoManager().EnterListAction( aName, aName, 0, nViewShellId );
634 bChanged = true;
637 OUString aFieldText = rEditEng.GetText( aFieldSel );
638 pOutliner->QuickInsertText( aFieldText, aFieldSel );
639 if (nPar == aSel.end.nPara)
641 nNewEnd = nNewEnd + aFieldText.getLength();
642 --nNewEnd;
649 if (bUpdate && bChanged)
651 pOutliner->GetUndoManager().LeaveListAction();
652 pOutliner->SetUpdateLayout( true );
655 if ( aOldSel == aSel ) // aSel is adjusted
656 aOldSel.end.nIndex = nNewEnd;
657 else
658 aOldSel.start.nIndex = nNewEnd; // if aOldSel is backwards
659 rOutView.SetSelection( aOldSel );
662 void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
664 SdrView* pView = mrViewData.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( SvxAdjust::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( SvxAdjust::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( SvxAdjust::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( SvxAdjust::Block, EE_PARA_JUST ) );
697 break;
699 case SID_ATTR_PARA_LINESPACE_10:
701 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
702 aItem.SetPropLineSpace( 100 );
703 aNewAttr.Put( aItem );
705 break;
707 case SID_ATTR_PARA_LINESPACE_15:
709 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
710 aItem.SetPropLineSpace( 150 );
711 aNewAttr.Put( aItem );
713 break;
715 case SID_ATTR_PARA_LINESPACE_20:
717 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, 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 = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
728 if( eEsc == SvxEscapement::Superscript )
729 aItem.SetEscapement( SvxEscapement::Off );
730 else
731 aItem.SetEscapement( SvxEscapement::Superscript );
732 aNewAttr.Put( aItem );
734 break;
736 case SID_SET_SUB_SCRIPT:
738 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
739 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
741 if( eEsc == SvxEscapement::Subscript )
742 aItem.SetEscapement( SvxEscapement::Off );
743 else
744 aItem.SetEscapement( SvxEscapement::Subscript );
745 aNewAttr.Put( aItem );
747 break;
749 case SID_TABLE_VERT_NONE:
750 case SID_TABLE_VERT_CENTER:
751 case SID_TABLE_VERT_BOTTOM:
753 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
754 if (nSlot == SID_TABLE_VERT_CENTER)
755 eTVA = SDRTEXTVERTADJUST_CENTER;
756 else if (nSlot == SID_TABLE_VERT_BOTTOM)
757 eTVA = SDRTEXTVERTADJUST_BOTTOM;
758 aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
760 break;
762 case SID_PARASPACE_INCREASE:
763 case SID_PARASPACE_DECREASE:
765 SvxULSpaceItem aULSpace( aEditAttr.Get( EE_PARA_ULSPACE ) );
766 sal_uInt16 nUpper = aULSpace.GetUpper();
767 sal_uInt16 nLower = aULSpace.GetLower();
769 if ( nSlot == SID_PARASPACE_INCREASE )
771 nUpper += 100;
772 nLower += 100;
774 else
776 nUpper = std::max< sal_Int16 >( nUpper - 100, 0 );
777 nLower = std::max< sal_Int16 >( nLower - 100, 0 );
780 aULSpace.SetUpper( nUpper );
781 aULSpace.SetLower( nLower );
782 aNewAttr.Put( aULSpace );
784 break;
786 default:
787 bSet = false;
790 bool bDone = true;
791 bool bArgsInReq = ( pArgs != nullptr );
793 if ( !bArgsInReq )
795 switch ( nSlot )
797 case SID_CELL_FORMAT_RESET:
798 case SID_TEXT_STANDARD:
800 OutlinerView* pOutView = pView->IsTextEdit() ?
801 pView->GetTextEditOutlinerView() : nullptr;
802 if ( pOutView )
803 pOutView->Paint( tools::Rectangle() );
805 SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aEmptyAttr( *aEditAttr.GetPool() );
806 SfxItemSetFixed<SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_MINFRAMEHEIGHT,
807 SDRATTR_TEXT_MAXFRAMEHEIGHT, SDRATTR_TEXT_MAXFRAMEWIDTH> aSizeAttr(*aEditAttr.GetPool());
809 aSizeAttr.Put(pView->GetAttrFromMarked(true));
810 pView->SetAttributes( aEmptyAttr, true );
812 if (IsNoteEdit())
814 pView->SetAttributes(aSizeAttr, false);
815 pView->GetTextEditObject()->AdjustTextFrameWidthAndHeight();
818 if ( pOutView )
820 lcl_RemoveFields( *pOutView );
821 pOutView->ShowCursor();
824 rReq.Done( aEmptyAttr );
825 mrViewData.GetScDrawView()->InvalidateDrawTextAttrs();
826 bDone = false; // already happened here
828 break;
830 case SID_GROW_FONT_SIZE:
831 case SID_SHRINK_FONT_SIZE:
833 OutlinerView* pOutView = pView->IsTextEdit() ?
834 pView->GetTextEditOutlinerView() : nullptr;
835 if ( pOutView )
837 if (SfxObjectShell* pObjSh = SfxObjectShell::Current())
839 const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* >
840 ( pObjSh->GetItem( SID_ATTR_CHAR_FONTLIST ) );
841 const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
842 pOutView->GetEditView().ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pFontList );
843 mrViewData.GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
845 bDone = false;
848 break;
850 case SID_CHAR_DLG_EFFECT:
851 case SID_CHAR_DLG: // dialog button
852 case SID_ATTR_CHAR_FONT: // Controller not shown
853 case SID_ATTR_CHAR_FONTHEIGHT:
854 bDone = ExecuteCharDlg( aEditAttr, aNewAttr , nSlot);
855 break;
857 case SID_PARA_DLG:
858 bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
859 break;
861 case SID_ATTR_CHAR_WEIGHT:
862 aNewAttr.Put( aEditAttr.Get( EE_CHAR_WEIGHT ) );
863 break;
865 case SID_ATTR_CHAR_POSTURE:
866 aNewAttr.Put( aEditAttr.Get( EE_CHAR_ITALIC ) );
867 break;
869 case SID_ATTR_CHAR_UNDERLINE:
870 aNewAttr.Put( aEditAttr.Get( EE_CHAR_UNDERLINE ) );
871 break;
873 case SID_ATTR_CHAR_OVERLINE:
874 aNewAttr.Put( aEditAttr.Get( EE_CHAR_OVERLINE ) );
875 break;
877 case SID_ATTR_CHAR_CONTOUR:
878 aNewAttr.Put( aEditAttr.Get( EE_CHAR_OUTLINE ) );
879 break;
881 case SID_ATTR_CHAR_SHADOWED:
882 aNewAttr.Put( aEditAttr.Get( EE_CHAR_SHADOW ) );
883 break;
885 case SID_ATTR_CHAR_STRIKEOUT:
886 aNewAttr.Put( aEditAttr.Get( EE_CHAR_STRIKEOUT ) );
887 break;
889 case SID_DRAWTEXT_ATTR_DLG:
891 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
892 VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog(mrViewData.GetDialogParent(), &aEditAttr, pView));
893 auto xRequest = std::make_shared<SfxRequest>(rReq);
894 rReq.Ignore(); // the 'old' request is not relevant any more
895 pDlg->StartExecuteAsync(
896 [this, pDlg, pArgs, aNewAttr, bSet, xRequest=std::move(xRequest), pView] (sal_Int32 nResult) mutable -> void
898 if ( RET_OK == nResult )
899 aNewAttr.Put( *pDlg->GetOutputItemSet() );
901 pDlg->disposeOnce();
903 SfxBindings& rBindings = mrViewData.GetBindings();
904 rBindings.Invalidate( SID_TABLE_VERT_NONE );
905 rBindings.Invalidate( SID_TABLE_VERT_CENTER );
906 rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
908 if ( bSet || RET_OK == nResult )
910 xRequest->Done( aNewAttr );
911 pArgs = xRequest->GetArgs();
913 if (pArgs)
915 // use args directly
916 pView->SetAttributes( *pArgs );
917 mrViewData.GetScDrawView()->InvalidateDrawTextAttrs();
922 break;
923 case SID_ATTR_CHAR_COLOR:
924 case SID_ATTR_CHAR_BACK_COLOR:
926 const sal_uInt16 nEEWhich = GetPool().GetWhichIDFromSlotID(nSlot);
927 const std::optional<NamedColor> oColor
928 = mrViewData.GetDocShell()->GetRecentColor(nSlot);
929 if (oColor.has_value())
931 const model::ComplexColor aCol = (*oColor).getComplexColor();
932 aNewAttr.Put(SvxColorItem(aCol.getFinalColor(), aCol, nEEWhich));
934 break;
939 if ( bSet || bDone )
941 rReq.Done( aNewAttr );
942 pArgs = rReq.GetArgs();
945 if ( !pArgs )
946 return;
948 if ( bArgsInReq &&
949 ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
950 nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
952 // font items from toolbox controller have to be applied for the right script type
954 // #i78017 establish the same behaviour as in Writer
955 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
956 if (nSlot == SID_ATTR_CHAR_FONT)
957 nScript = pView->GetScriptType();
959 SfxItemPool& rPool = GetPool();
960 SvxScriptSetItem aSetItem( nSlot, rPool );
961 sal_uInt16 nWhich = rPool.GetWhichIDFromSlotID( nSlot );
962 aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
964 pView->SetAttributes( aSetItem.GetItemSet() );
966 else if( nSlot == SID_ATTR_PARA_LRSPACE )
968 sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
969 const SvxLRSpaceItem& rItem = static_cast<const SvxLRSpaceItem&>(
970 pArgs->Get( nId ));
971 SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aAttr( GetPool() );
972 nId = EE_PARA_LRSPACE;
973 SvxLRSpaceItem aLRSpaceItem(rItem.GetLeft(), rItem.GetRight(),
974 rItem.GetTextFirstLineOffset(), nId);
975 aAttr.Put( aLRSpaceItem );
976 pView->SetAttributes( aAttr );
978 else if( nSlot == SID_ATTR_PARA_LINESPACE )
980 SvxLineSpacingItem aLineSpaceItem = static_cast<const SvxLineSpacingItem&>(pArgs->Get(
981 GetPool().GetWhichIDFromSlotID(nSlot)));
982 SfxItemSetFixed<EE_PARA_SBL, EE_PARA_SBL> aAttr( GetPool() );
983 aAttr.Put( aLineSpaceItem );
984 pView->SetAttributes( aAttr );
986 else if( nSlot == SID_ATTR_PARA_ULSPACE )
988 SvxULSpaceItem aULSpaceItem = static_cast<const SvxULSpaceItem&>(pArgs->Get(
989 GetPool().GetWhichIDFromSlotID(nSlot)));
990 SfxItemSetFixed<EE_PARA_ULSPACE, EE_PARA_ULSPACE> aAttr( GetPool() );
991 aULSpaceItem.SetWhich(EE_PARA_ULSPACE);
992 aAttr.Put( aULSpaceItem );
993 pView->SetAttributes( aAttr );
995 else
997 // use args directly
998 pView->SetAttributes( *pArgs );
1000 mrViewData.GetScDrawView()->InvalidateDrawTextAttrs();
1003 void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet )
1005 if ( IsNoteEdit() )
1007 // issue 21255 - Notes now support rich text formatting.
1010 bool bDisableCTLFont = !::SvtCTLOptions::IsCTLFontEnabled();
1011 bool bDisableVerticalText = !SvtCJKOptions::IsVerticalTextEnabled();
1013 SdrView* pView = mrViewData.GetScDrawView();
1014 SfxItemSet aAttrSet(pView->GetModel().GetItemPool());
1015 pView->GetAttributes(aAttrSet);
1017 // direct attributes
1019 rDestSet.Put( aAttrSet );
1021 // choose font info according to selection script type
1023 SvtScriptType nScript = pView->GetScriptType();
1025 // #i55929# input-language-dependent script type (depends on input language if nothing selected)
1026 SvtScriptType nInputScript = nScript;
1027 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1028 if (pOutView && !pOutView->GetSelection().HasRange())
1030 LanguageType nInputLang = mrViewData.GetActiveWin()->GetInputLanguage();
1031 if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
1032 nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
1035 // #i55929# according to spec, nInputScript is used for font and font height only
1036 if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SfxItemState::UNKNOWN )
1037 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
1038 if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SfxItemState::UNKNOWN )
1039 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
1040 if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SfxItemState::UNKNOWN )
1041 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
1042 if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SfxItemState::UNKNOWN )
1043 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
1044 // Alignment
1046 SvxAdjust eAdj = aAttrSet.Get(EE_PARA_JUST).GetAdjust();
1047 switch( eAdj )
1049 case SvxAdjust::Left:
1051 rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, true ) );
1052 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
1054 break;
1055 case SvxAdjust::Center:
1057 rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, true ) );
1058 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
1060 break;
1061 case SvxAdjust::Right:
1063 rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, true ) );
1064 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
1066 break;
1067 case SvxAdjust::Block:
1069 rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, true ) );
1070 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
1072 break;
1073 default:
1075 // added to avoid warnings
1078 // pseudo slots for Format menu
1079 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SvxAdjust::Left ) );
1080 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SvxAdjust::Center ) );
1081 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SvxAdjust::Right ) );
1082 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SvxAdjust::Block ) );
1084 SvxLRSpaceItem aLR = aAttrSet.Get( EE_PARA_LRSPACE );
1085 aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
1086 rDestSet.Put(aLR);
1087 Invalidate( SID_ATTR_PARA_LRSPACE );
1088 SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
1089 if ( eState == SfxItemState::INVALID )
1090 rDestSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
1091 //xuxu for Line Space
1092 SvxLineSpacingItem aLineSP = aAttrSet.Get( EE_PARA_SBL );
1093 aLineSP.SetWhich(SID_ATTR_PARA_LINESPACE);
1094 rDestSet.Put(aLineSP);
1095 Invalidate(SID_ATTR_PARA_LINESPACE);
1096 eState = aAttrSet.GetItemState( EE_PARA_SBL );
1097 if ( eState == SfxItemState::INVALID )
1098 rDestSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
1099 //xuxu for UL Space
1100 SvxULSpaceItem aULSP = aAttrSet.Get( EE_PARA_ULSPACE );
1101 aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
1102 rDestSet.Put(aULSP);
1103 Invalidate(SID_ATTR_PARA_ULSPACE);
1104 Invalidate(SID_PARASPACE_INCREASE);
1105 Invalidate(SID_PARASPACE_DECREASE);
1106 eState = aAttrSet.GetItemState( EE_PARA_ULSPACE );
1107 if( eState >= SfxItemState::DEFAULT )
1109 if ( !aULSP.GetUpper() && !aULSP.GetLower() )
1110 rDestSet.DisableItem( SID_PARASPACE_DECREASE );
1112 else
1114 rDestSet.DisableItem( SID_PARASPACE_INCREASE );
1115 rDestSet.DisableItem( SID_PARASPACE_DECREASE );
1116 rDestSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
1119 // Line spacing
1121 sal_uInt16 nLineSpace = aAttrSet.Get( EE_PARA_SBL ).GetPropLineSpace();
1122 switch( nLineSpace )
1124 case 100:
1125 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, true ) );
1126 break;
1127 case 150:
1128 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, true ) );
1129 break;
1130 case 200:
1131 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, true ) );
1132 break;
1135 // super-/subscript
1136 SvxEscapement eEsc = static_cast<SvxEscapement>(aAttrSet.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
1137 rDestSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
1138 rDestSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
1140 // Underline
1141 eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE );
1142 if ( eState == SfxItemState::INVALID )
1144 rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
1145 rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1146 rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1147 rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1149 else
1151 FontLineStyle eUnderline = aAttrSet.Get(EE_CHAR_UNDERLINE).GetLineStyle();
1152 rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_SINGLE, eUnderline == LINESTYLE_SINGLE));
1153 rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_DOUBLE, eUnderline == LINESTYLE_DOUBLE));
1154 rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_DOTTED, eUnderline == LINESTYLE_DOTTED));
1155 rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_NONE, eUnderline == LINESTYLE_NONE));
1158 // horizontal / vertical
1160 bool bLeftToRight = true;
1162 SdrOutliner* pOutl = pView->GetTextEditOutliner();
1163 if( pOutl )
1165 if( pOutl->IsVertical() )
1166 bLeftToRight = false;
1168 else
1169 bLeftToRight = aAttrSet.Get( SDRATTR_TEXTDIRECTION ).GetValue() == css::text::WritingMode_LR_TB;
1171 if ( bDisableVerticalText )
1173 rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
1174 rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
1176 else
1178 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
1179 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
1182 // left-to-right or right-to-left
1184 if ( !bLeftToRight || bDisableCTLFont )
1186 // disabled if vertical
1187 rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1188 rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1190 else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SfxItemState::INVALID )
1192 rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1193 rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1195 else
1197 SvxFrameDirection eAttrDir = aAttrSet.Get( EE_PARA_WRITINGDIR ).GetValue();
1198 if ( eAttrDir == SvxFrameDirection::Environment )
1200 // get "environment" direction from page style
1201 if ( mrViewData.GetDocument().GetEditTextDirection( mrViewData.GetTabNo() ) == EEHorizontalTextDirection::R2L )
1202 eAttrDir = SvxFrameDirection::Horizontal_RL_TB;
1203 else
1204 eAttrDir = SvxFrameDirection::Horizontal_LR_TB;
1206 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == SvxFrameDirection::Horizontal_LR_TB ) ) );
1207 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == SvxFrameDirection::Horizontal_RL_TB ) ) );
1211 void ScDrawTextObjectBar::ExecuteTrans( const SfxRequest& rReq )
1213 TransliterationFlags nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
1214 if ( nType == TransliterationFlags::NONE )
1215 return;
1217 ScDrawView* pView = mrViewData.GetScDrawView();
1218 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1219 if ( pOutView )
1221 // change selected text in object
1222 pOutView->TransliterateText( nType );
1224 else
1226 //! apply to whole objects?
1230 void ScDrawTextObjectBar::GetStatePropPanelAttr(SfxItemSet &rSet)
1232 SfxWhichIter aIter( rSet );
1233 sal_uInt16 nWhich = aIter.FirstWhich();
1235 SdrView* pView = mrViewData.GetScDrawView();
1237 SfxItemSet aEditAttr(pView->GetModel().GetItemPool());
1238 pView->GetAttributes(aEditAttr);
1239 //SfxItemSet aAttrs( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
1241 while ( nWhich )
1243 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1244 ? GetPool().GetSlotId(nWhich)
1245 : nWhich;
1246 switch ( nSlotId )
1248 case SID_TABLE_VERT_NONE:
1249 case SID_TABLE_VERT_CENTER:
1250 case SID_TABLE_VERT_BOTTOM:
1251 bool bContour = false;
1252 SfxItemState eConState = aEditAttr.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1253 if( eConState != SfxItemState::INVALID )
1255 bContour = aEditAttr.Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue();
1257 if (bContour) break;
1259 SfxItemState eVState = aEditAttr.GetItemState( SDRATTR_TEXT_VERTADJUST );
1260 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1262 //if(SfxItemState::INVALID != eVState && SfxItemState::INVALID != eHState)
1263 if(SfxItemState::INVALID != eVState)
1265 SdrTextVertAdjust eTVA = aEditAttr.Get(SDRATTR_TEXT_VERTADJUST).GetValue();
1266 bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) ||
1267 (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) ||
1268 (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM);
1269 rSet.Put(SfxBoolItem(nSlotId, bSet));
1271 else
1273 rSet.Put(SfxBoolItem(nSlotId, false));
1275 break;
1277 nWhich = aIter.NextWhich();
1281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */