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