LibreOffice Module sc (master)  1
drtxtob.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <comphelper/string.hxx>
21 #include <scitems.hxx>
22 
23 #include <editeng/adjustitem.hxx>
24 #include <svx/clipfmtitem.hxx>
25 #include <editeng/contouritem.hxx>
27 #include <editeng/eeitem.hxx>
28 #include <editeng/editeng.hxx>
29 #include <editeng/editview.hxx>
31 #include <editeng/flditem.hxx>
32 #include <editeng/flstitem.hxx>
33 #include <editeng/fontitem.hxx>
34 #include <editeng/frmdiritem.hxx>
35 #include <editeng/lrspitem.hxx>
36 #include <editeng/lspcitem.hxx>
37 #include <editeng/ulspitem.hxx>
39 #include <svx/hlnkitem.hxx>
40 #include <svx/svdoutl.hxx>
41 #include <svx/sdooitm.hxx>
42 #include <editeng/postitem.hxx>
44 #include <editeng/shdditem.hxx>
45 #include <editeng/udlnitem.hxx>
46 #include <editeng/wghtitem.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/objface.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <sfx2/request.hxx>
52 #include <sfx2/viewfrm.hxx>
53 #include <svtools/cliplistener.hxx>
54 #include <vcl/transfer.hxx>
55 #include <svl/stritem.hxx>
56 #include <svl/whiter.hxx>
57 #include <svl/languageoptions.hxx>
58 #include <svl/cjkoptions.hxx>
59 #include <svl/ctloptions.hxx>
60 
61 #include <svx/svxdlg.hxx>
62 #include <vcl/EnumContext.hxx>
63 #include <vcl/unohelp2.hxx>
64 
65 #include <sc.hrc>
66 #include <globstr.hrc>
67 #include <scresid.hxx>
68 #include <scmod.hxx>
69 #include <drtxtob.hxx>
70 #include <viewdata.hxx>
71 #include <document.hxx>
72 #include <drawview.hxx>
73 #include <viewutil.hxx>
74 #include <tabvwsh.hxx>
75 #include <gridwin.hxx>
76 
77 #define ShellClass_ScDrawTextObjectBar
78 #include <scslots.hxx>
79 
80 using namespace ::com::sun::star;
81 
83 
84 void ScDrawTextObjectBar::InitInterface_Impl()
85 {
86  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT,
87  SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
88  ToolbarId::Text_Toolbox_Sc);
89 
90  GetStaticInterface()->RegisterPopupMenu("drawtext");
91 
92  GetStaticInterface()->RegisterChildWindow(ScGetFontWorkId());
93 }
94 
95 
96 // disable not wanted accelerators
97 
99 {
100  SfxWhichIter aIter(rSet);
101  sal_uInt16 nWhich = aIter.FirstWhich();
102 
103  while (nWhich)
104  {
105  rSet.DisableItem( nWhich );
106  nWhich = aIter.NextWhich();
107  }
108 }
109 
111  SfxShell(rData.GetViewShell()),
112  mrViewData(rData),
113  bPastePossible(false)
114 {
116 
117  // At the switching-over the UndoManager is changed to edit mode
119  SetUndoManager( pMgr );
121  {
122  pMgr->SetMaxUndoActionCount( 0 );
123  }
124 
125  SetName("DrawText");
127 }
128 
130 {
131  if ( mxClipEvtLstnr.is() )
132  {
133  mxClipEvtLstnr->RemoveListener( mrViewData.GetActiveWin() );
134 
135  // The listener may just now be waiting for the SolarMutex and call the link
136  // afterwards, in spite of RemoveListener. So the link has to be reset, too.
137  mxClipEvtLstnr->ClearCallbackLink();
138  }
139 }
140 
141 // Functions
142 
144 {
146  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
147  Outliner* pOutliner = pView->GetTextEditOutliner();
148 
149  if (!pOutView || !pOutliner)
150  {
151  ExecuteGlobal( rReq ); // on whole objects
152  return;
153  }
154 
155  const SfxItemSet* pReqArgs = rReq.GetArgs();
156  sal_uInt16 nSlot = rReq.GetSlot();
157  switch ( nSlot )
158  {
159  case SID_COPY:
160  pOutView->Copy();
161  break;
162 
163  case SID_CUT:
164  pOutView->Cut();
165  break;
166 
167  case SID_PASTE:
168  pOutView->PasteSpecial();
169  break;
170 
171  case SID_CLIPBOARD_FORMAT_ITEMS:
172  {
173  SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
174  const SfxPoolItem* pItem;
175  if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
176  if (auto pIntItem = dynamic_cast<const SfxUInt32Item*>( pItem))
177  nFormat = static_cast<SotClipboardFormatId>(pIntItem->GetValue());
178 
179  if ( nFormat != SotClipboardFormatId::NONE )
180  {
181  if (nFormat == SotClipboardFormatId::STRING)
182  pOutView->Paste();
183  else
184  pOutView->PasteSpecial();
185  }
186  }
187  break;
188 
189  case SID_PASTE_SPECIAL:
190  ExecutePasteContents( rReq );
191  break;
192 
193  case SID_PASTE_UNFORMATTED:
194  pOutView->Paste();
195  break;
196 
197  case SID_SELECTALL:
198  {
199  sal_Int32 nCount = pOutliner->GetParagraphCount();
200  ESelection aSel( 0,0,nCount,0 );
201  pOutView->SetSelection( aSel );
202  }
203  break;
204 
205  case SID_CHARMAP:
206  {
207  const SvxFontItem& rItem = pOutView->GetAttribs().Get(EE_CHAR_FONTINFO);
208 
209  OUString aString;
210  std::shared_ptr<SvxFontItem> aNewItem(std::make_shared<SvxFontItem>(EE_CHAR_FONTINFO));
211 
212  const SfxItemSet *pArgs = rReq.GetArgs();
213  const SfxPoolItem* pItem = nullptr;
214  if( pArgs )
215  pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
216 
217  if ( pItem )
218  {
219  aString = static_cast<const SfxStringItem*>(pItem)->GetValue();
220  const SfxPoolItem* pFtItem = nullptr;
221  pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
222  const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>( pFtItem );
223  if ( pFontItem )
224  {
225  const OUString& aFontName(pFontItem->GetValue());
226  vcl::Font aFont(aFontName, Size(1,1)); // Size only because of CTOR
227  aNewItem = std::make_shared<SvxFontItem>(
228  aFont.GetFamilyType(), aFont.GetFamilyName(),
229  aFont.GetStyleName(), aFont.GetPitch(),
230  aFont.GetCharSet(), ATTR_FONT);
231  }
232  else
233  {
234  aNewItem.reset(rItem.Clone());
235  }
236  }
237  else
239 
240  if ( !aString.isEmpty() )
241  {
242  SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
243  // tdf#125054
244  // checked against original, indeed aNewItem looks as if it can have
245  // either WhichID EE_CHAR_FONTINFO or ATTR_FONT when it was reset
246  // above, original uses '= SvxFontItem(..., ATTR_FONT).
247  // BUT beware: the operator=() did not copy the WhichID when resetting,
248  // so it indeed has WhichID of EE_CHAR_FONTINFO despite copying an Item
249  // that was constructed using ATTR_FONT as WhichID (!)
250  aSet.Put( *aNewItem, EE_CHAR_FONTINFO );
251 
252  // If nothing is selected, then SetAttribs of the View selects a word
253  pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() );
254  pOutView->InsertText(aString);
255  }
256 
257  Invalidate( SID_ATTR_CHAR_FONT );
258  }
259  break;
260 
261  case SID_HYPERLINK_SETLINK:
262  if( pReqArgs )
263  {
264  const SfxPoolItem* pItem;
265  if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
266  {
267  const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
268  const OUString& rName = pHyper->GetName();
269  const OUString& rURL = pHyper->GetURL();
270  const OUString& rTarget = pHyper->GetTargetFrame();
272 
273  bool bDone = false;
274  if (eMode == HLINK_DEFAULT || eMode == HLINK_FIELD)
275  {
276  pOutView->SelectFieldAtCursor();
277 
278  // insert new field
279  SvxURLField aURLField( rURL, rName, SvxURLFormat::Repr );
280  aURLField.SetTargetFrame( rTarget );
281  SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
282  pOutView->InsertField( aURLItem );
283 
284  bDone = true;
285  }
286 
287  if (!bDone)
288  ExecuteGlobal( rReq ); // normal at View
289 
290  // If "text" is received by InsertURL of ViewShell, then the DrawShell is turned off !!!
291  }
292  }
293  break;
294 
295  case SID_OPEN_HYPERLINK:
296  if (const SvxFieldData* pField = pOutView->GetFieldAtCursor())
297  {
298  if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
299  {
300  ScGlobal::OpenURL(pURLField->GetURL(), pURLField->GetTargetFrame(), true);
301  }
302  }
303  break;
304 
305  case SID_EDIT_HYPERLINK:
306  {
307  // Ensure the field is selected first
308  pOutView->SelectFieldAtCursor();
309  mrViewData.GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_HYPERLINK_DIALOG);
310  }
311  break;
312 
313  case SID_COPY_HYPERLINK_LOCATION:
314  {
315  const SvxFieldData* pField = pOutView->GetFieldAtCursor();
316  if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
317  {
318  uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
319  = pOutView->GetWindow()->GetClipboard();
320  vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
321  }
322  }
323  break;
324 
325  case SID_REMOVE_HYPERLINK:
326  {
327  // Ensure the field is selected first
329  }
330  break;
331 
332  case SID_ENABLE_HYPHENATION:
333  case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
334  case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
335  pView->ScEndTextEdit(); // end text edit before switching direction
336  ExecuteGlobal( rReq );
337  // restore consistent state between shells and functions:
338  mrViewData.GetDispatcher().Execute(SID_OBJECT_SELECT, SfxCallMode::SLOT | SfxCallMode::RECORD);
339  break;
340 
341  case SID_THES:
342  {
343  OUString aReplaceText;
344  const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(SID_THES);
345  if (pItem2)
346  aReplaceText = pItem2->GetValue();
347  if (!aReplaceText.isEmpty())
348  ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
349  }
350  break;
351 
352  case SID_THESAURUS:
353  {
354  pOutView->StartThesaurus(rReq.GetFrameWeld());
355  }
356  break;
357  }
358 }
359 
361 {
363  bool bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK);
364  bool bDisableFontWork = false;
365 
366  if (IsNoteEdit())
367  {
368  // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
369  bDisableFontWork = true;
370  }
371 
372  if ( bDisableFontWork )
373  rSet.DisableItem( SID_FONTWORK );
374  else
375  rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
376 
377  if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SfxItemState::UNKNOWN )
378  {
379  SvxHyperlinkItem aHLinkItem;
380  SdrView* pView = mrViewData.GetScDrawView();
381  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
382  if ( pOutView )
383  {
384  bool bField = false;
385  const SvxFieldData* pField = pOutView->GetFieldAtCursor();
386  if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
387  {
388  aHLinkItem.SetName( pURLField->GetRepresentation() );
389  aHLinkItem.SetURL( pURLField->GetURL() );
390  aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
391  bField = true;
392  }
393 
394  if (!bField)
395  {
396  // use selected text as name for urls
397  OUString sReturn = pOutView->GetSelected();
398  sal_Int32 nLen = std::min<sal_Int32>(sReturn.getLength(), 255);
399  sReturn = sReturn.copy(0, nLen);
400  aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
401  }
402  }
403  rSet.Put(aHLinkItem);
404  }
405 
406  if (rSet.GetItemState(SID_OPEN_HYPERLINK) != SfxItemState::UNKNOWN
407  || rSet.GetItemState(SID_EDIT_HYPERLINK) != SfxItemState::UNKNOWN
408  || rSet.GetItemState(SID_COPY_HYPERLINK_LOCATION) != SfxItemState::UNKNOWN
409  || rSet.GetItemState(SID_REMOVE_HYPERLINK) != SfxItemState::UNKNOWN)
410  {
411  SdrView* pView = mrViewData.GetScDrawView();
413  {
414  rSet.DisableItem( SID_OPEN_HYPERLINK );
415  rSet.DisableItem( SID_EDIT_HYPERLINK );
416  rSet.DisableItem( SID_COPY_HYPERLINK_LOCATION );
417  rSet.DisableItem( SID_REMOVE_HYPERLINK );
418  }
419  }
420 
421  if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SfxItemState::UNKNOWN )
422  ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
423  if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SfxItemState::UNKNOWN )
424  ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
425  if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SfxItemState::UNKNOWN )
426  ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA );
427  if( rSet.GetItemState( SID_TRANSLITERATE_KATAKANA ) != SfxItemState::UNKNOWN )
428  ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAKANA );
429 
430  if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SfxItemState::UNKNOWN )
431  {
432  SdrView* pView = mrViewData.GetScDrawView();
433  SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
434  pView->GetAttributes( aAttrs );
435  if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
436  {
437  bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue();
438  rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
439  }
440  }
441 
442  if ( rSet.GetItemState( SID_THES ) != SfxItemState::UNKNOWN ||
443  rSet.GetItemState( SID_THESAURUS ) != SfxItemState::UNKNOWN )
444  {
445  SdrView * pView = mrViewData.GetScDrawView();
446  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
447 
448  OUString aStatusVal;
449  LanguageType nLang = LANGUAGE_NONE;
450  bool bIsLookUpWord = false;
451  if ( pOutView )
452  {
453  EditView& rEditView = pOutView->GetEditView();
454  bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
455  }
456  rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
457 
458  // disable thesaurus main menu and context menu entry if there is nothing to look up
459  bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
460  if (!bIsLookUpWord || !bCanDoThesaurus)
461  rSet.DisableItem( SID_THES );
462  if (!bCanDoThesaurus)
463  rSet.DisableItem( SID_THESAURUS );
464  }
465 
466  if (GetObjectShell()->isContentExtractionLocked())
467  {
468  rSet.DisableItem(SID_COPY);
469  rSet.DisableItem(SID_CUT);
470  }
471 }
472 
473 IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
474 {
475  bPastePossible = ( pDataHelper->HasFormat( SotClipboardFormatId::STRING ) || pDataHelper->HasFormat( SotClipboardFormatId::RTF )
476  || pDataHelper->HasFormat( SotClipboardFormatId::RICHTEXT ) );
477 
478  SfxBindings& rBindings = mrViewData.GetBindings();
479  rBindings.Invalidate( SID_PASTE );
480  rBindings.Invalidate( SID_PASTE_SPECIAL );
481  rBindings.Invalidate( SID_PASTE_UNFORMATTED );
482  rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
483 }
484 
486 {
487  SdrView* pView = mrViewData.GetScDrawView();
488  if ( !pView->GetTextEditOutlinerView() )
489  {
490  GetGlobalClipState( rSet );
491  return;
492  }
493 
494  if ( !mxClipEvtLstnr.is() )
495  {
496  // create listener
497  mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
499  mxClipEvtLstnr->AddListener( pWin );
500 
501  // get initial state
503  bPastePossible = ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) || aDataHelper.HasFormat( SotClipboardFormatId::RTF )
504  || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) );
505  }
506 
507  SfxWhichIter aIter( rSet );
508  sal_uInt16 nWhich = aIter.FirstWhich();
509  while (nWhich)
510  {
511  switch (nWhich)
512  {
513  case SID_PASTE:
514  case SID_PASTE_SPECIAL:
515  case SID_PASTE_UNFORMATTED:
516  if( !bPastePossible )
517  rSet.DisableItem( nWhich );
518  break;
519  case SID_CLIPBOARD_FORMAT_ITEMS:
520  if ( bPastePossible )
521  {
522  SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
523  TransferableDataHelper aDataHelper(
525 
526  if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
527  aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
528  if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
529  aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
530  if ( aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
531  aFormats.AddClipbrdFormat( SotClipboardFormatId::RICHTEXT );
532 
533  rSet.Put( aFormats );
534  }
535  else
536  rSet.DisableItem( nWhich );
537  break;
538  }
539  nWhich = aIter.NextWhich();
540  }
541 }
542 
543 // Attributes
544 
546 {
547  // Underline
548 
549  SdrView* pView = mrViewData.GetScDrawView();
550 
551  sal_uInt16 nSlot = rReq.GetSlot();
552 
553  SfxItemSet aSet( pView->GetDefaultAttr() );
554 
555  SfxItemSet aViewAttr(pView->GetModel()->GetItemPool());
556  pView->GetAttributes(aViewAttr);
557 
558  // Underline
559  FontLineStyle eOld = aViewAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
560  FontLineStyle eNew = eOld;
561  switch (nSlot)
562  {
563  case SID_ULINE_VAL_NONE:
564  eNew = LINESTYLE_NONE;
565  break;
566  case SID_ULINE_VAL_SINGLE:
567  eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
568  break;
569  case SID_ULINE_VAL_DOUBLE:
570  eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
571  break;
572  case SID_ULINE_VAL_DOTTED:
573  eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
574  break;
575  default:
576  break;
577  }
578  aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
579 
580  pView->SetAttributes( aSet );
581  rReq.Done();
583 }
584 
585 static void lcl_RemoveFields( OutlinerView& rOutView )
586 {
588 
589  Outliner* pOutliner = rOutView.GetOutliner();
590  if (!pOutliner) return;
591 
592  ESelection aOldSel = rOutView.GetSelection();
593  ESelection aSel = aOldSel;
594  aSel.Adjust();
595  sal_Int32 nNewEnd = aSel.nEndPos;
596 
597  bool bUpdate = pOutliner->IsUpdateLayout();
598  bool bChanged = false;
599 
601  EditEngine& rEditEng = const_cast<EditEngine&>(pOutliner->GetEditEngine());
602 
603  sal_Int32 nParCount = pOutliner->GetParagraphCount();
604  for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
605  if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
606  {
607  std::vector<sal_Int32> aPortions;
608  rEditEng.GetPortions( nPar, aPortions );
609 
610  for ( size_t nPos = aPortions.size(); nPos; )
611  {
612  --nPos;
613  sal_Int32 nEnd = aPortions[ nPos ];
614  sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
615  // fields are single characters
616  if ( nEnd == nStart+1 &&
617  ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
618  ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) )
619  {
620  ESelection aFieldSel( nPar, nStart, nPar, nEnd );
621  SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
622  if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SfxItemState::SET )
623  {
624  if (!bChanged)
625  {
626  if (bUpdate)
627  pOutliner->SetUpdateLayout( false );
628  OUString aName = ScResId( STR_UNDO_DELETECONTENTS );
629  ViewShellId nViewShellId(-1);
631  nViewShellId = pViewSh->GetViewShellId();
632  pOutliner->GetUndoManager().EnterListAction( aName, aName, 0, nViewShellId );
633  bChanged = true;
634  }
635 
636  OUString aFieldText = rEditEng.GetText( aFieldSel );
637  pOutliner->QuickInsertText( aFieldText, aFieldSel );
638  if ( nPar == aSel.nEndPara )
639  {
640  nNewEnd = nNewEnd + aFieldText.getLength();
641  --nNewEnd;
642  }
643  }
644  }
645  }
646  }
647 
648  if (bUpdate && bChanged)
649  {
650  pOutliner->GetUndoManager().LeaveListAction();
651  pOutliner->SetUpdateLayout( true );
652  }
653 
654  if ( aOldSel == aSel ) // aSel is adjusted
655  aOldSel.nEndPos = nNewEnd;
656  else
657  aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards
658  rOutView.SetSelection( aOldSel );
659 }
660 
662 {
663  SdrView* pView = mrViewData.GetScDrawView();
664  const SfxItemSet* pArgs = rReq.GetArgs();
665  sal_uInt16 nSlot = rReq.GetSlot();
666 
667  SfxItemSet aEditAttr( pView->GetModel()->GetItemPool() );
668  pView->GetAttributes( aEditAttr );
669  SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
670 
671  bool bSet = true;
672  switch ( nSlot )
673  {
674  case SID_ALIGNLEFT:
675  case SID_ALIGN_ANY_LEFT:
676  case SID_ATTR_PARA_ADJUST_LEFT:
677  aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
678  break;
679 
680  case SID_ALIGNCENTERHOR:
681  case SID_ALIGN_ANY_HCENTER:
682  case SID_ATTR_PARA_ADJUST_CENTER:
683  aNewAttr.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
684  break;
685 
686  case SID_ALIGNRIGHT:
687  case SID_ALIGN_ANY_RIGHT:
688  case SID_ATTR_PARA_ADJUST_RIGHT:
689  aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
690  break;
691 
692  case SID_ALIGNBLOCK:
693  case SID_ALIGN_ANY_JUSTIFIED:
694  case SID_ATTR_PARA_ADJUST_BLOCK:
695  aNewAttr.Put( SvxAdjustItem( SvxAdjust::Block, EE_PARA_JUST ) );
696  break;
697 
698  case SID_ATTR_PARA_LINESPACE_10:
699  {
701  aItem.SetPropLineSpace( 100 );
702  aNewAttr.Put( aItem );
703  }
704  break;
705 
706  case SID_ATTR_PARA_LINESPACE_15:
707  {
709  aItem.SetPropLineSpace( 150 );
710  aNewAttr.Put( aItem );
711  }
712  break;
713 
714  case SID_ATTR_PARA_LINESPACE_20:
715  {
717  aItem.SetPropLineSpace( 200 );
718  aNewAttr.Put( aItem );
719  }
720  break;
721 
722  case SID_SET_SUPER_SCRIPT:
723  {
725  SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
726 
727  if( eEsc == SvxEscapement::Superscript )
728  aItem.SetEscapement( SvxEscapement::Off );
729  else
730  aItem.SetEscapement( SvxEscapement::Superscript );
731  aNewAttr.Put( aItem );
732  }
733  break;
734 
735  case SID_SET_SUB_SCRIPT:
736  {
738  SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
739 
740  if( eEsc == SvxEscapement::Subscript )
741  aItem.SetEscapement( SvxEscapement::Off );
742  else
743  aItem.SetEscapement( SvxEscapement::Subscript );
744  aNewAttr.Put( aItem );
745  }
746  break;
747 
748  case SID_TABLE_VERT_NONE:
749  case SID_TABLE_VERT_CENTER:
750  case SID_TABLE_VERT_BOTTOM:
751  {
753  if (nSlot == SID_TABLE_VERT_CENTER)
755  else if (nSlot == SID_TABLE_VERT_BOTTOM)
757  aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
758  }
759  break;
760 
761  case SID_PARASPACE_INCREASE:
762  case SID_PARASPACE_DECREASE:
763  {
764  SvxULSpaceItem aULSpace( aEditAttr.Get( EE_PARA_ULSPACE ) );
765  sal_uInt16 nUpper = aULSpace.GetUpper();
766  sal_uInt16 nLower = aULSpace.GetLower();
767 
768  if ( nSlot == SID_PARASPACE_INCREASE )
769  {
770  nUpper += 100;
771  nLower += 100;
772  }
773  else
774  {
775  nUpper = std::max< sal_Int16 >( nUpper - 100, 0 );
776  nLower = std::max< sal_Int16 >( nLower - 100, 0 );
777  }
778 
779  aULSpace.SetUpper( nUpper );
780  aULSpace.SetLower( nLower );
781  aNewAttr.Put( aULSpace );
782  }
783  break;
784 
785  default:
786  bSet = false;
787  }
788 
789  bool bDone = true;
790  bool bArgsInReq = ( pArgs != nullptr );
791 
792  if ( !bArgsInReq )
793  {
794  switch ( nSlot )
795  {
796  case SID_TEXT_STANDARD: // delete hard text attributes
797  {
798  OutlinerView* pOutView = pView->IsTextEdit() ?
799  pView->GetTextEditOutlinerView() : nullptr;
800  if ( pOutView )
801  pOutView->Paint( tools::Rectangle() );
802 
803  SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aEmptyAttr( *aEditAttr.GetPool() );
804  pView->SetAttributes( aEmptyAttr, true );
805 
806  if ( pOutView )
807  {
808  lcl_RemoveFields( *pOutView );
809  pOutView->ShowCursor();
810  }
811 
812  rReq.Done( aEmptyAttr );
814  bDone = false; // already happened here
815  }
816  break;
817 
818  case SID_GROW_FONT_SIZE:
819  case SID_SHRINK_FONT_SIZE:
820  {
821  OutlinerView* pOutView = pView->IsTextEdit() ?
822  pView->GetTextEditOutlinerView() : nullptr;
823  if ( pOutView )
824  {
825  const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* >
826  ( SfxObjectShell::Current()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
827  const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
828  pOutView->GetEditView().ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pFontList );
829  mrViewData.GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
830  bDone = false;
831  }
832  }
833  break;
834 
835  case SID_CHAR_DLG_EFFECT:
836  case SID_CHAR_DLG: // dialog button
837  case SID_ATTR_CHAR_FONT: // Controller not shown
838  case SID_ATTR_CHAR_FONTHEIGHT:
839  bDone = ExecuteCharDlg( aEditAttr, aNewAttr , nSlot);
840  break;
841 
842  case SID_PARA_DLG:
843  bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
844  break;
845 
846  case SID_ATTR_CHAR_WEIGHT:
847  aNewAttr.Put( aEditAttr.Get( EE_CHAR_WEIGHT ) );
848  break;
849 
850  case SID_ATTR_CHAR_POSTURE:
851  aNewAttr.Put( aEditAttr.Get( EE_CHAR_ITALIC ) );
852  break;
853 
854  case SID_ATTR_CHAR_UNDERLINE:
855  aNewAttr.Put( aEditAttr.Get( EE_CHAR_UNDERLINE ) );
856  break;
857 
858  case SID_ATTR_CHAR_OVERLINE:
859  aNewAttr.Put( aEditAttr.Get( EE_CHAR_OVERLINE ) );
860  break;
861 
862  case SID_ATTR_CHAR_CONTOUR:
863  aNewAttr.Put( aEditAttr.Get( EE_CHAR_OUTLINE ) );
864  break;
865 
866  case SID_ATTR_CHAR_SHADOWED:
867  aNewAttr.Put( aEditAttr.Get( EE_CHAR_SHADOW ) );
868  break;
869 
870  case SID_ATTR_CHAR_STRIKEOUT:
871  aNewAttr.Put( aEditAttr.Get( EE_CHAR_STRIKEOUT ) );
872  break;
873 
874  case SID_DRAWTEXT_ATTR_DLG:
875  {
878 
879  bDone = ( RET_OK == pDlg->Execute() );
880 
881  if ( bDone )
882  aNewAttr.Put( *pDlg->GetOutputItemSet() );
883 
884  pDlg.disposeAndClear();
885 
886  SfxBindings& rBindings = mrViewData.GetBindings();
887  rBindings.Invalidate( SID_TABLE_VERT_NONE );
888  rBindings.Invalidate( SID_TABLE_VERT_CENTER );
889  rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
890  }
891  break;
892  }
893  }
894 
895  if ( bSet || bDone )
896  {
897  rReq.Done( aNewAttr );
898  pArgs = rReq.GetArgs();
899  }
900 
901  if ( !pArgs )
902  return;
903 
904  if ( bArgsInReq &&
905  ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
906  nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
907  {
908  // font items from toolbox controller have to be applied for the right script type
909 
910  // #i78017 establish the same behaviour as in Writer
911  SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
912  if (nSlot == SID_ATTR_CHAR_FONT)
913  nScript = pView->GetScriptType();
914 
915  SfxItemPool& rPool = GetPool();
916  SvxScriptSetItem aSetItem( nSlot, rPool );
917  sal_uInt16 nWhich = rPool.GetWhich( nSlot );
918  aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
919 
920  pView->SetAttributes( aSetItem.GetItemSet() );
921  }
922  else if( nSlot == SID_ATTR_PARA_LRSPACE )
923  {
924  sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
925  const SvxLRSpaceItem& rItem = static_cast<const SvxLRSpaceItem&>(
926  pArgs->Get( nId ));
928  nId = EE_PARA_LRSPACE;
929  SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
930  rItem.GetRight(), rItem.GetTextLeft(),
931  rItem.GetTextFirstLineOffset(), nId );
932  aAttr.Put( aLRSpaceItem );
933  pView->SetAttributes( aAttr );
934  }
935  else if( nSlot == SID_ATTR_PARA_LINESPACE )
936  {
937  SvxLineSpacingItem aLineSpaceItem = static_cast<const SvxLineSpacingItem&>(pArgs->Get(
938  GetPool().GetWhich(nSlot)));
940  aAttr.Put( aLineSpaceItem );
941  pView->SetAttributes( aAttr );
942  }
943  else if( nSlot == SID_ATTR_PARA_ULSPACE )
944  {
945  SvxULSpaceItem aULSpaceItem = static_cast<const SvxULSpaceItem&>(pArgs->Get(
946  GetPool().GetWhich(nSlot)));
948  aULSpaceItem.SetWhich(EE_PARA_ULSPACE);
949  aAttr.Put( aULSpaceItem );
950  pView->SetAttributes( aAttr );
951  }
952  else
953  {
954  // use args directly
955  pView->SetAttributes( *pArgs );
956  }
958 }
959 
961 {
962  if ( IsNoteEdit() )
963  {
964  // issue 21255 - Notes now support rich text formatting.
965  }
966 
967  bool bDisableCTLFont = !SvtCTLOptions().IsCTLFontEnabled();
968  bool bDisableVerticalText = !SvtCJKOptions::IsVerticalTextEnabled();
969 
970  SdrView* pView = mrViewData.GetScDrawView();
971  SfxItemSet aAttrSet(pView->GetModel()->GetItemPool());
972  pView->GetAttributes(aAttrSet);
973 
974  // direct attributes
975 
976  rDestSet.Put( aAttrSet );
977 
978  // choose font info according to selection script type
979 
980  SvtScriptType nScript = pView->GetScriptType();
981 
982  // #i55929# input-language-dependent script type (depends on input language if nothing selected)
983  SvtScriptType nInputScript = nScript;
984  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
985  if (pOutView && !pOutView->GetSelection().HasRange())
986  {
988  if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
989  nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
990  }
991 
992  // #i55929# according to spec, nInputScript is used for font and font height only
993  if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SfxItemState::UNKNOWN )
994  ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
995  if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SfxItemState::UNKNOWN )
996  ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
997  if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SfxItemState::UNKNOWN )
998  ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
999  if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SfxItemState::UNKNOWN )
1000  ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
1001  // Alignment
1002 
1003  SvxAdjust eAdj = aAttrSet.Get(EE_PARA_JUST).GetAdjust();
1004  switch( eAdj )
1005  {
1006  case SvxAdjust::Left:
1007  {
1008  rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, true ) );
1009  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
1010  }
1011  break;
1012  case SvxAdjust::Center:
1013  {
1014  rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, true ) );
1015  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
1016  }
1017  break;
1018  case SvxAdjust::Right:
1019  {
1020  rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, true ) );
1021  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
1022  }
1023  break;
1024  case SvxAdjust::Block:
1025  {
1026  rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, true ) );
1027  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
1028  }
1029  break;
1030  default:
1031  {
1032  // added to avoid warnings
1033  }
1034  }
1035  // pseudo slots for Format menu
1036  rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SvxAdjust::Left ) );
1037  rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SvxAdjust::Center ) );
1038  rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SvxAdjust::Right ) );
1039  rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SvxAdjust::Block ) );
1040 
1041  SvxLRSpaceItem aLR = aAttrSet.Get( EE_PARA_LRSPACE );
1042  aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
1043  rDestSet.Put(aLR);
1044  Invalidate( SID_ATTR_PARA_LRSPACE );
1045  SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
1046  if ( eState == SfxItemState::DONTCARE )
1047  rDestSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
1048  //xuxu for Line Space
1049  SvxLineSpacingItem aLineSP = aAttrSet.Get( EE_PARA_SBL );
1050  aLineSP.SetWhich(SID_ATTR_PARA_LINESPACE);
1051  rDestSet.Put(aLineSP);
1052  Invalidate(SID_ATTR_PARA_LINESPACE);
1053  eState = aAttrSet.GetItemState( EE_PARA_SBL );
1054  if ( eState == SfxItemState::DONTCARE )
1055  rDestSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
1056  //xuxu for UL Space
1057  SvxULSpaceItem aULSP = aAttrSet.Get( EE_PARA_ULSPACE );
1058  aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
1059  rDestSet.Put(aULSP);
1060  Invalidate(SID_ATTR_PARA_ULSPACE);
1061  Invalidate(SID_PARASPACE_INCREASE);
1062  Invalidate(SID_PARASPACE_DECREASE);
1063  eState = aAttrSet.GetItemState( EE_PARA_ULSPACE );
1064  if( eState >= SfxItemState::DEFAULT )
1065  {
1066  if ( !aULSP.GetUpper() && !aULSP.GetLower() )
1067  rDestSet.DisableItem( SID_PARASPACE_DECREASE );
1068  }
1069  else
1070  {
1071  rDestSet.DisableItem( SID_PARASPACE_INCREASE );
1072  rDestSet.DisableItem( SID_PARASPACE_DECREASE );
1073  rDestSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
1074  }
1075 
1076  // Line spacing
1077 
1078  sal_uInt16 nLineSpace = aAttrSet.Get( EE_PARA_SBL ).GetPropLineSpace();
1079  switch( nLineSpace )
1080  {
1081  case 100:
1082  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, true ) );
1083  break;
1084  case 150:
1085  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, true ) );
1086  break;
1087  case 200:
1088  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, true ) );
1089  break;
1090  }
1091 
1092  // super-/subscript
1093  SvxEscapement eEsc = static_cast<SvxEscapement>(aAttrSet.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
1094  rDestSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
1095  rDestSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
1096 
1097  // Underline
1098  eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE );
1099  if ( eState == SfxItemState::DONTCARE )
1100  {
1101  rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
1102  rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1103  rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1104  rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1105  }
1106  else
1107  {
1108  FontLineStyle eUnderline = aAttrSet.Get(EE_CHAR_UNDERLINE).GetLineStyle();
1109  rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_SINGLE, eUnderline == LINESTYLE_SINGLE));
1110  rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_DOUBLE, eUnderline == LINESTYLE_DOUBLE));
1111  rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_DOTTED, eUnderline == LINESTYLE_DOTTED));
1112  rDestSet.Put(SfxBoolItem(SID_ULINE_VAL_NONE, eUnderline == LINESTYLE_NONE));
1113  }
1114 
1115  // horizontal / vertical
1116 
1117  bool bLeftToRight = true;
1118 
1119  SdrOutliner* pOutl = pView->GetTextEditOutliner();
1120  if( pOutl )
1121  {
1122  if( pOutl->IsVertical() )
1123  bLeftToRight = false;
1124  }
1125  else
1126  bLeftToRight = aAttrSet.Get( SDRATTR_TEXTDIRECTION ).GetValue() == css::text::WritingMode_LR_TB;
1127 
1128  if ( bDisableVerticalText )
1129  {
1130  rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
1131  rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
1132  }
1133  else
1134  {
1135  rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
1136  rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
1137  }
1138 
1139  // left-to-right or right-to-left
1140 
1141  if ( !bLeftToRight || bDisableCTLFont )
1142  {
1143  // disabled if vertical
1144  rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1145  rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1146  }
1147  else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SfxItemState::DONTCARE )
1148  {
1149  rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1150  rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1151  }
1152  else
1153  {
1154  SvxFrameDirection eAttrDir = aAttrSet.Get( EE_PARA_WRITINGDIR ).GetValue();
1155  if ( eAttrDir == SvxFrameDirection::Environment )
1156  {
1157  // get "environment" direction from page style
1158  if ( mrViewData.GetDocument().GetEditTextDirection( mrViewData.GetTabNo() ) == EEHorizontalTextDirection::R2L )
1159  eAttrDir = SvxFrameDirection::Horizontal_RL_TB;
1160  else
1161  eAttrDir = SvxFrameDirection::Horizontal_LR_TB;
1162  }
1163  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == SvxFrameDirection::Horizontal_LR_TB ) ) );
1164  rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == SvxFrameDirection::Horizontal_RL_TB ) ) );
1165  }
1166 }
1167 
1169 {
1171  if ( nType == TransliterationFlags::NONE )
1172  return;
1173 
1174  ScDrawView* pView = mrViewData.GetScDrawView();
1175  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1176  if ( pOutView )
1177  {
1178  // change selected text in object
1179  pOutView->TransliterateText( nType );
1180  }
1181  else
1182  {
1184  }
1185 }
1186 
1188 {
1189  SfxWhichIter aIter( rSet );
1190  sal_uInt16 nWhich = aIter.FirstWhich();
1191 
1192  SdrView* pView = mrViewData.GetScDrawView();
1193 
1194  SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
1195  pView->GetAttributes(aEditAttr);
1196  //SfxItemSet aAttrs( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
1197 
1198  while ( nWhich )
1199  {
1200  sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1201  ? GetPool().GetSlotId(nWhich)
1202  : nWhich;
1203  switch ( nSlotId )
1204  {
1205  case SID_TABLE_VERT_NONE:
1206  case SID_TABLE_VERT_CENTER:
1207  case SID_TABLE_VERT_BOTTOM:
1208  bool bContour = false;
1209  SfxItemState eConState = aEditAttr.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1210  if( eConState != SfxItemState::DONTCARE )
1211  {
1212  bContour = aEditAttr.Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue();
1213  }
1214  if (bContour) break;
1215 
1216  SfxItemState eVState = aEditAttr.GetItemState( SDRATTR_TEXT_VERTADJUST );
1217  //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1218 
1219  //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState)
1220  if(SfxItemState::DONTCARE != eVState)
1221  {
1222  SdrTextVertAdjust eTVA = aEditAttr.Get(SDRATTR_TEXT_VERTADJUST).GetValue();
1223  bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) ||
1224  (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) ||
1225  (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM);
1226  rSet.Put(SfxBoolItem(nSlotId, bSet));
1227  }
1228  else
1229  {
1230  rSet.Put(SfxBoolItem(nSlotId, false));
1231  }
1232  break;
1233  }
1234  nWhich = aIter.NextWhich();
1235  }
1236 }
1237 
1238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetURL(const OUString &rURL)
SfxViewFrame * GetViewFrame() const
void Adjust()
OString stripEnd(std::string_view rIn, char c)
#define LANGUAGE_NONE
OUString GetText(LineEnd eEnd=LINEEND_LF) const
static void CopyStringTo(const OUString &rContent, const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rxClipboard, const vcl::ILibreOfficeKitNotifier *pNotifier=nullptr)
void SetTargetFrame(const OUString &rFrm)
void ExecuteToggle(SfxRequest &rReq)
Definition: drtxtob.cxx:545
sal_Int32 nStartPara
static void HideDisabledSlot(SfxItemSet &rSet, SfxBindings &rBindings, sal_uInt16 nSlotId)
Definition: viewutil.cxx:284
SDRTEXTVERTADJUST_TOP
bool IsNoteEdit() const
Definition: drtxtob2.cxx:42
void PasteSpecial()
void PutItemForScriptType(SvtScriptType nScriptType, const SfxPoolItem &rItem)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:89
void InsertText(const OUString &rNew, bool bSelect=false)
sal_uInt16 GetLower() const
#define LINE_SPACE_DEFAULT_HEIGHT
void SetEscapement(const SvxEscapement eNew)
static void PutItemScript(SfxItemSet &rShellSet, const SfxItemSet &rCoreSet, sal_uInt16 nWhichId, SvtScriptType nScript)
Definition: viewutil.cxx:49
void SelectFieldAtCursor()
virtual const SfxItemSet * GetOutputItemSet() const =0
std::string GetValue
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard()
static void StateDisableItems(SfxItemSet &rSet)
Definition: drtxtob.cxx:98
const OUString & GetTargetFrame() const
void ExecuteAttr(SfxRequest &rReq)
Definition: drtxtob.cxx:661
SfxDispatcher * GetDispatcher()
void ShowCursor(bool bGotoCursor=true, bool bActivate=false)
static SvxAbstractDialogFactory * Create()
tools::Long GetRight() const
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_CONTOURFRAME(SDRATTR_MISC_FIRST+21)
void disposeAndClear()
FilterGroup & rTarget
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
static void OpenURL(const OUString &rURL, const OUString &rTarget, bool bIgnoreSettings=false)
Open the specified URL.
Definition: global.cxx:759
void InvalidateItem(sal_uInt16 nWhich)
sal_Int16 nId
sal_uInt16 FirstWhich()
void TransliterateText(TransliterationFlags nTransliterationMode)
SCTAB GetTabNo() const
Definition: viewdata.hxx:394
SvxFrameDirection
void Done(bool bRemove=false)
sal_Int32 GetParagraphCount() const
ScDocument & GetDocument() const
Definition: viewdata.hxx:379
void ChangeFontSize(bool bGrow, const FontList *pList)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+15)
static bool HasThesaurusLanguage(LanguageType nLang)
Definition: scmod.cxx:2202
static SfxObjectShell * Current()
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
virtual SfxUndoManager * GetUndoManager()
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
bool IsCTLFontEnabled() const
void ExecutePasteContents(SfxRequest &rReq)
Definition: drtxtob1.cxx:98
bool HasFormat(SotClipboardFormatId nFormat) const
virtual SvxFontItem * Clone(SfxItemPool *pPool=nullptr) const override
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxLineSpacingItem > EE_PARA_SBL(EE_PARA_START+14)
SfxItemSet GetAttribs(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags=GetAttribsFlags::ALL) const
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
sal_uInt16 NextWhich()
void GetClipState(SfxItemSet &rSet)
Definition: drtxtob.cxx:485
void SetTargetFrame(const OUString &rTarget)
SfxUndoManager & GetUndoManager()
void SetPropLineSpace(const sal_uInt16 nProp)
LINESTYLE_NONE
constexpr TypedWhichId< SvxLRSpaceItem > EE_PARA_LRSPACE(EE_PARA_START+12)
constexpr TypedWhichId< SvxULSpaceItem > EE_PARA_ULSPACE(EE_PARA_START+13)
int nCount
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
ScViewData & mrViewData
Definition: drtxtob.hxx:37
Mode eMode
const SfxItemSet & GetDefaultAttr() const
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SotClipboardFormatId
bool IsUpdateLayout() const
sal_Int32 nEndPos
virtual SvtScriptType GetScriptType() const
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3137
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
TransliterationFlags
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
EditView & GetEditView() const
SfxItemPool & GetPool() const
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:356
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
SDRTEXTVERTADJUST_BOTTOM
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)
void Execute(SfxRequest &rReq)
Definition: drtxtob.cxx:143
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
tools::Long GetTextLeft() const
sal_Int32 nEndPara
const SdrOutliner * GetTextEditOutliner() const
SvtScriptType
const OUString & GetURL() const
void ExecuteTrans(const SfxRequest &rReq)
Definition: drtxtob.cxx:1168
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
static void GetGlobalClipState(SfxItemSet &rSet)
Definition: drtxtob2.cxx:112
SvxAdjust
IMPL_LINK(ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper *, pDataHelper, void)
Definition: drtxtob.cxx:473
SfxBindings & GetBindings()
Definition: viewdata.cxx:3097
#define LANGUAGE_SYSTEM
void InvalidateDrawTextAttrs()
Definition: drawview.cxx:162
SfxBindings & GetBindings()
constexpr TypedWhichId< SdrTextVertAdjustItem > SDRATTR_TEXT_VERTADJUST(SDRATTR_MISC_FIRST+8)
const OUString & GetValue() const
ScDrawTextObjectBar(ScViewData &rData)
Definition: drtxtob.cxx:110
const T * GetArg(sal_uInt16 nSlotId) const
tools::Long GetLeft() const
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
void SetPool(SfxItemPool *pNewPool)
OUString GetSelected() const
SvxLinkInsertMode
LINESTYLE_SINGLE
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3125
#define LANGUAGE_DONTKNOW
short GetTextFirstLineOffset() const
void Paste(bool bUseSpecial=false)
const OutlinerView * GetTextEditOutlinerView() const
HLINK_FIELD
Outliner * GetOutliner() const
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
EESpellState StartThesaurus(weld::Widget *pDialogParent)
void SetName(const OUString &rName)
void SetName(const OUString &rName)
weld::Window * GetDialogParent()
Definition: viewdata.cxx:3119
rtl::Reference< TransferableClipboardListener > mxClipEvtLstnr
Definition: drtxtob.hxx:38
void InsertField(const SvxFieldItem &rFld)
SfxItemPool * GetPool() const
void ExecuteGlobal(SfxRequest &rReq)
Definition: drtxtob2.cxx:49
static void RemoveURLField(EditView &pEditView)
const EditEngine & GetEditEngine() const
void QuickInsertText(const OUString &rText, const ESelection &rSel)
#define SFX_OBJECTBAR_OBJECT
size_t LeaveListAction()
ESelection GetSelection() const
virtual VclPtr< SfxAbstractTabDialog > CreateTextTabDialog(weld::Window *pParent, const SfxItemSet *pAttrSet, SdrView *pView)=0
weld::Window * GetFrameWeld() const
virtual ~ScDrawTextObjectBar() override
Definition: drtxtob.cxx:129
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const
Definition: documen8.cxx:357
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
void SetSelection(const ESelection &)
bool HasChildWindow(sal_uInt16)
HLINK_DEFAULT
bool HasRange() const
bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext(OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView)
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1038
SfxItemState
virtual bool IsTextEdit() const final override
void DisableItem(sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static void ExecuteCharMap(const SvxFontItem &rOldFont, const ScTabViewShell &rShell)
Definition: viewutil.cxx:318
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
static TransliterationFlags GetTransliterationType(sal_uInt16 nSlotID)
Definition: viewutil.cxx:98
#define GetWhich(nSlot)
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
LINESTYLE_DOTTED
virtual void Invalidate(sal_uInt16 nId=0)
bool ExecuteParaDlg(const SfxItemSet &rArgs, SfxItemSet &rOutSet)
Definition: drtxtob1.cxx:63
OUString aName
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList)
SfxDispatcher & GetDispatcher()
Definition: viewdata.cxx:3103
RET_OK
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
vcl::Window * GetWindow() const
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
void GetStatePropPanelAttr(SfxItemSet &)
Definition: drtxtob.cxx:1187
const SvxFieldData * GetFieldAtCursor() const
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
const SfxItemSet & GetEmptyItemSet() const
bool SetUpdateLayout(bool bUpdate)
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:896
void GetState(SfxItemSet &rSet)
Definition: drtxtob.cxx:360
void AddClipbrdFormat(SotClipboardFormatId nId)
bool IsVerticalTextEnabled()
SvxEscapement
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
const OUString & GetName() const
SvxLinkInsertMode GetInsertMode() const
SfxObjectShell * GetSfxDocShell() const
Definition: viewdata.hxx:357
bool IsUndoEnabled() const
Definition: document.hxx:1535
SfxItemSet GetAttribs()
void GetAttrState(SfxItemSet &rSet)
Definition: drtxtob.cxx:960
const SfxItemPool & GetItemPool() const
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
LINESTYLE_DOUBLE
const FontList * GetFontList() const
static void lcl_RemoveFields(OutlinerView &rOutView)
Definition: drtxtob.cxx:585
LanguageType GetInputLanguage() const
FontLineStyle
sal_uInt16 ScGetFontWorkId()
Definition: drtxtob2.cxx:37
bool ExecuteCharDlg(const SfxItemSet &rArgs, SfxItemSet &rOutSet, sal_uInt16 nSlot)
Definition: drtxtob1.cxx:40
SdrModel * GetModel() const
static bool IsCursorAtURLField(const EditView &pEditView)
void SetContextName(const OUString &rsContextName)
SdrTextVertAdjust
virtual SfxObjectShell * GetObjectShell()
void EDITENG_DLLPUBLIC ReplaceTextWithSynonym(EditView &rEditView, const OUString &rSynonmText)
static bool IsWhich(sal_uInt16 nId)
sal_uInt16 nPos
sal_uInt16 GetUpper() const
SDRTEXTVERTADJUST_CENTER
sal_Int32 nStartPos
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
void Paint(const tools::Rectangle &rRect, OutputDevice *pTargetDevice=nullptr)