LibreOffice Module sw (master)  1
wrtsh1.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 <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/container/XChild.hpp>
22 #include <com/sun/star/embed/EmbedMisc.hpp>
23 #include <com/sun/star/embed/EmbedStates.hpp>
24 #include <com/sun/star/embed/EmbedVerbs.hpp>
25 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
26 #include <com/sun/star/chart2/XChartDocument.hpp>
27 #include <com/sun/star/util/XModifiable.hpp>
28 
29 #include <hintids.hxx>
30 #include <sot/exchange.hxx>
31 #include <svx/xfillit0.hxx>
32 #include <svx/hdft.hxx>
33 #include <svx/svdview.hxx>
34 #include <svl/itemiter.hxx>
35 #include <tools/bigint.hxx>
36 #include <svtools/insdlg.hxx>
37 #include <sfx2/ipclient.hxx>
39 #include <editeng/svxacorr.hxx>
40 #include <editeng/ulspitem.hxx>
41 #include <vcl/graph.hxx>
42 #include <unotools/charclass.hxx>
44 #include <svx/svxdlg.hxx>
45 #include <svx/extrusionbar.hxx>
46 #include <svx/fontworkbar.hxx>
47 #include <dialoghelp.hxx>
48 #include <frmfmt.hxx>
49 #include <fmtftn.hxx>
50 #include <fmthdft.hxx>
51 #include <fmtpdsc.hxx>
52 #include <txtfrm.hxx>
53 #include <wdocsh.hxx>
54 #include <swmodule.hxx>
55 #include <wrtsh.hxx>
56 #include <view.hxx>
57 #include <cmdid.h>
58 #include <pagedesc.hxx>
59 #include <frmmgr.hxx>
60 #include <swundo.hxx>
61 #include <swcli.hxx>
62 #include <poolfmt.hxx>
63 #include <edtwin.hxx>
64 #include <fmtcol.hxx>
65 #include <swtable.hxx>
66 #include <viscrs.hxx>
67 #include <swdtflvr.hxx>
68 #include <doc.hxx>
70 #include <SwCapObjType.hxx>
71 #include <SwStyleNameMapper.hxx>
72 #include <sfx2/request.hxx>
73 #include <paratr.hxx>
74 #include <ndtxt.hxx>
75 #include <editeng/acorrcfg.hxx>
76 #include <IMark.hxx>
77 #include <sfx2/bindings.hxx>
78 #include <flyfrm.hxx>
79 
80 // -> #111827#
81 #include <SwRewriter.hxx>
82 #include <strings.hrc>
83 // <- #111827#
84 
86 #include <sfx2/viewfrm.hxx>
87 #include <vcl/uitest/logger.hxx>
89 #include <osl/diagnose.h>
90 
91 #include <PostItMgr.hxx>
92 #include <FrameControlsManager.hxx>
93 #include <fldmgr.hxx>
94 #include <docufld.hxx>
96 #include <fmtfld.hxx>
97 
98 #include <sfx2/msgpool.hxx>
99 #include <sfx2/msg.hxx>
100 #include <svtools/embedhlp.hxx>
101 #include <svx/postattr.hxx>
102 #include <comphelper/lok.hxx>
103 #include <memory>
104 
105 #include <frmtool.hxx>
106 #include <viewopt.hxx>
107 
108 using namespace sw::mark;
109 using namespace com::sun::star;
110 namespace {
111 
112 void collectUIInformation(const OUString& rAction, const OUString& aParameters)
113 {
114  EventDescription aDescription;
115  aDescription.aAction = rAction;
116  aDescription.aParameters = {{"parameters", aParameters}};
117  aDescription.aID = "writer_edit";
118  aDescription.aKeyWord = "SwEditWinUIObject";
119  aDescription.aParent = "MainWindow";
120  UITestLogger::getInstance().logEvent(aDescription);
121 }
122 
123 }
124 
126 
127 static bool lcl_IsAllowed(const SwWrtShell* rSh)
128 {
130  {
131  SwTextNode* pTextNode = rSh->GetCursor()->GetNode().GetTextNode();
132  if (pTextNode && pTextNode->IsOutline())
133  {
134  // disallow if this is an outline node having folded content
135  bool bVisible = true;
136  pTextNode->GetAttrOutlineContentVisible(bVisible);
137  if (!bVisible)
138  return false;
139  }
140  }
141  return true;
142 }
143 
144 #define BITFLD_INI_LIST \
145  m_bClearMark = \
146  m_bIns = true;\
147  m_bAddMode = \
148  m_bBlockMode = \
149  m_bExtMode = \
150  m_bInSelect = \
151  m_bLayoutMode = \
152  m_bSelWrd = \
153  m_bSelLn = \
154  m_bRetainSelection = false; \
155  m_bIsInClickToEdit = false;
156 
158 {
160  if( pACorr && !pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord |
161  ACFlags::AddNonBrkSpace | ACFlags::ChgOrdinalNumber | ACFlags::TransliterateRTL |
162  ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect ))
163  pACorr = nullptr;
164  return pACorr;
165 }
166 
167 void SwWrtShell::NoEdit(bool bHideCursor)
168 {
169  if(bHideCursor)
170  HideCursor();
171 }
172 
174 {
175  if (CanInsert())
176  {
177  ShowCursor();
178  }
179 }
180 
182 {
183  SwMvContext aMvContext(this);
184  if(IsEndPara() && !IsSttPara())
185  return true;
186 
187  return IsEndWord();
188 }
189 
190 // Insert string
191 void SwWrtShell::InsertByWord( const OUString & rStr)
192 {
193  if( rStr.isEmpty() )
194  return;
195 
196  bool bDelim = GetAppCharClass().isLetterNumeric( rStr, 0 );
197  sal_Int32 nPos = 0, nStt = 0;
198  for( ; nPos < rStr.getLength(); nPos++ )
199  {
200  bool bTmpDelim = GetAppCharClass().isLetterNumeric( rStr, nPos );
201  if( bTmpDelim != bDelim )
202  {
203  Insert( rStr.copy( nStt, nPos - nStt ));
204  nStt = nPos;
205  }
206  }
207  if( nStt != nPos )
208  Insert( rStr.copy( nStt, nPos - nStt ));
209 }
210 
211 void SwWrtShell::Insert( const OUString &rStr )
212 {
213  ResetCursorStack();
214  if( !CanInsert() )
215  return;
216 
217  bool bStarted = false;
218  bool bHasSel = HasSelection(),
219  bCallIns = m_bIns /*|| bHasSel*/;
220  bool bDeleted = false;
221 
222  const auto CharItems = svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_RSID - 1,
223  RES_CHRATR_RSID + 1, RES_CHRATR_END - 1,
224  RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT>;
225  SfxItemSet aCharAttrSet(GetAttrPool(), CharItems);
226 
227  if( bHasSel || ( !m_bIns && SelectHiddenRange() ) )
228  {
229  // Only here parenthesizing, because the normal
230  // insert is already in parentheses at Editshell.
231  StartAllAction();
232 
233  SwRewriter aRewriter;
234 
235  aRewriter.AddRule(UndoArg1, GetCursorDescr());
236  aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
237  {
238  OUString aTmpStr = SwResId(STR_START_QUOTE) +
239  rStr + SwResId(STR_END_QUOTE);
240 
241  aRewriter.AddRule(UndoArg3, aTmpStr);
242  }
243 
244  // tdf#79717 Save character formatting of the start of the selection
245  const SwPosition *pStart = GetCursor()->Start();
246  SwPaM aPaM(pStart->nNode.GetNode(), pStart->nContent.GetIndex(),
247  pStart->nNode.GetNode(), pStart->nContent.GetIndex() + 1);
248  GetPaMAttr(&aPaM, aCharAttrSet);
249 
250  StartUndo(SwUndoId::REPLACE, &aRewriter);
251  bStarted = true;
252  Push();
253  bDeleted = DelRight();
254  Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore selection (if tracking changes)
255  NormalizePam(false); // tdf#127635 put point at the end of deletion
256  ClearMark();
257  }
258 
259  bCallIns ?
260  SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr );
261 
262  if( bDeleted )
263  {
264  // tdf#79717 Restore formatting of the deleted selection
265  SwPosition* pEnd = GetCursor()->Start();
266  SwPaM aPaM(pEnd->nNode.GetNode(), pEnd->nContent.GetIndex() - rStr.getLength(),
267  pEnd->nNode.GetNode(), pEnd->nContent.GetIndex());
268 
269  SetAttrSet(aCharAttrSet, SetAttrMode::DEFAULT, &aPaM);
270  }
271 
272  if( bStarted )
273  {
274  EndUndo();
275  EndAllAction();
276  }
277 }
278 
279 // Maximum height limit not possible, because the maximum height
280 // of the current frame can not be obtained.
281 
282 void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
283  const Graphic &rGrf, SwFlyFrameAttrMgr *pFrameMgr,
284  RndStdIds nAnchorType )
285 {
286  ResetCursorStack();
287  if ( !CanInsert() )
288  return;
289 
290  StartAllAction();
291 
292  SwRewriter aRewriter;
293  aRewriter.AddRule(UndoArg1, SwResId(STR_GRAPHIC));
294 
295  StartUndo(SwUndoId::INSERT, &aRewriter);
296 
297  if ( HasSelection() )
298  DelRight();
299  // Inserted graphics in its own paragraph,
300  // if at the end of a non-empty paragraph.
301  //For i120928,avoid to split node
302 
303  EnterSelFrameMode();
304 
305  bool bSetGrfSize = true;
306  bool bOwnMgr = false;
307 
308  if ( !pFrameMgr )
309  {
310  bOwnMgr = true;
311  pFrameMgr = new SwFlyFrameAttrMgr( true, this, Frmmgr_Type::GRF, nullptr );
312 
313  // CAUTION
314  // GetAttrSet makes an adjustment
315  // While pasting is a SwFrameSize present
316  // because of the DEF-Framesize
317  // These must be removed explicitly for the optimal size.
318  pFrameMgr->DelAttr(RES_FRM_SIZE);
319 
320  if (nAnchorType != RndStdIds::FLY_AT_PARA)
321  // Something other than at-para was requested.
322  pFrameMgr->SetAnchor(nAnchorType);
323  }
324  else
325  {
326  Size aSz( pFrameMgr->GetSize() );
327  if ( !aSz.Width() || !aSz.Height() )
328  {
329  aSz.setWidth(567);
330  aSz.setHeight( 567);
331  pFrameMgr->SetSize( aSz );
332  }
333  else if ( aSz.Width() != DFLT_WIDTH && aSz.Height() != DFLT_HEIGHT )
334  bSetGrfSize = false;
335 
337  }
338 
339  // during change tracking, insert the image anchored as character
340  // (to create an SwRangeRedline on its anchor point)
341  if ( IsRedlineOn() && nAnchorType != RndStdIds::FLY_AS_CHAR )
342  pFrameMgr->SetAnchor( RndStdIds::FLY_AS_CHAR );
343 
344  // Insert the graphic
345  SwFEShell::Insert(rPath, rFilter, &rGrf, &pFrameMgr->GetAttrSet());
346  if ( bOwnMgr )
347  pFrameMgr->UpdateAttrMgr();
348 
349  if( bSetGrfSize )
350  {
351  Size aGrfSize, aBound = GetGraphicDefaultSize();
352  GetGrfSize( aGrfSize );
353 
354  // Add the margin attributes to GrfSize,
355  // because these counts at the margin additionally
356  aGrfSize.AdjustWidth(pFrameMgr->CalcWidthBorder() );
357  aGrfSize.AdjustHeight(pFrameMgr->CalcHeightBorder() );
358 
359  const BigInt aTempWidth( aGrfSize.Width() );
360  const BigInt aTempHeight( aGrfSize.Height());
361 
362  // Fit width if necessary, scale down the height proportional thereafter.
363  if( aGrfSize.Width() > aBound.Width() )
364  {
365  aGrfSize.setWidth( aBound.Width() );
366  aGrfSize.setHeight( BigInt(aBound.Width()) * aTempHeight / aTempWidth );
367  }
368  // Fit height if necessary, scale down the width proportional thereafter.
369  if( aGrfSize.Height() > aBound.Height() )
370  {
371  aGrfSize.setHeight( aBound.Height() );
372  aGrfSize.setWidth( BigInt(aBound.Height()) * aTempWidth / aTempHeight );
373  }
374  pFrameMgr->SetSize( aGrfSize );
375  pFrameMgr->UpdateFlyFrame();
376  }
377  if ( bOwnMgr )
378  delete pFrameMgr;
379 
380  EndUndo();
381  EndAllAction();
382 }
383 
384 // Insert an OLE-Object into the CORE.
385 // if no object is transferred, then one will be created.
386 
388  sal_uInt16 nSlotId )
389 {
390  ResetCursorStack();
391  if( !CanInsert() )
392  return;
393 
394  if( !xRef.is() )
395  {
396  // temporary storage
398  uno::Reference < embed::XStorage > xStor = comphelper::OStorageHelper::GetTemporaryStorage();
399  bool bDoVerb = true;
400  if ( pName )
401  {
403  OUString aName;
404  // TODO/LATER: get aspect?
405  xObj.Assign( aCnt.CreateEmbeddedObject( pName->GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT );
406  }
407  else
408  {
409  SvObjectServerList aServerList;
410  switch (nSlotId)
411  {
412  case SID_INSERT_OBJECT:
413  {
414  aServerList.FillInsertObjects();
415  aServerList.Remove( SwDocShell::Factory().GetClassId() );
416  [[fallthrough]];
417  }
418 
419  // TODO/LATER: recording! Convert properties to items
420  case SID_INSERT_FLOATINGFRAME:
421  {
422  SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
423  const SfxSlot* pSlot = pSlotPool->GetSlot(nSlotId);
424  OString aCmd = OString::Concat(".uno:") + pSlot->GetUnoName();
426  ScopedVclPtr<SfxAbstractInsertObjectDialog> pDlg(pFact->CreateInsertObjectDialog(GetFrameWeld(mxDoc->GetDocShell()),
427  OUString::fromUtf8( aCmd ), xStor, &aServerList));
428  if (pDlg)
429  {
430  pDlg->Execute();
431  bDoVerb = pDlg->IsCreateNew();
432  OUString aIconMediaType;
433  uno::Reference< io::XInputStream > xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
434  xObj.Assign( pDlg->GetObject(),
435  xIconMetaFile.is() ? embed::Aspects::MSOLE_ICON : embed::Aspects::MSOLE_CONTENT );
436  if ( xIconMetaFile.is() )
437  xObj.SetGraphicStream( xIconMetaFile, aIconMediaType );
438  }
439 
440  break;
441  }
442 
443  default:
444  break;
445  }
446  }
447 
448  if ( xObj.is() )
449  {
450  if( InsertOleObject( xObj ) && bDoVerb )
451  {
452  SfxInPlaceClient* pClient = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
453  if ( !pClient )
454  {
455  pClient = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
456  SetCheckForOLEInCaption( true );
457  }
458 
459  if ( xObj.GetViewAspect() == embed::Aspects::MSOLE_ICON )
460  {
461  SwRect aArea = GetAnyCurRect( CurRectType::FlyEmbeddedPrt, nullptr, xObj.GetObject() );
462  aArea.Pos() += GetAnyCurRect( CurRectType::FlyEmbedded, nullptr, xObj.GetObject() ).Pos();
463  MapMode aMapMode( MapUnit::MapTwip );
464  Size aSize = xObj.GetSize( &aMapMode );
465  aArea.Width( aSize.Width() );
466  aArea.Height( aSize.Height() );
467  RequestObjectResize( aArea, xObj.GetObject() );
468  }
469  else
470  CalcAndSetScale( xObj );
471 
472  //#50270# We don't need to handle error, this is handled by the
473  //DoVerb in the SfxViewShell
474  pClient->DoVerb(embed::EmbedVerbs::MS_OLEVERB_SHOW);
475 
476  // TODO/LATER: set document name - should be done in Client
477  }
478  }
479  }
480  else
481  {
482  if( HasSelection() )
483  DelRight();
484  InsertOleObject( xRef );
485  }
486 }
487 
488 // Insert object into the Core.
489 // From ClipBoard or Insert
490 
492 {
493  //tdf#125100 Ensure that ole object is initially shown as pictogram
494  comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = mxDoc->GetDocShell()->getEmbeddedObjectContainer();
495  bool bSaveUserAllowsLinkUpdate = rEmbeddedObjectContainer.getUserAllowsLinkUpdate();
496  rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
497 
498  ResetCursorStack();
499  StartAllAction();
500 
501  StartUndo(SwUndoId::INSERT);
502 
503  //Some differences between StarMath and any other objects:
504  //1. Selections should be deleted. For StarMath the Text should be
505  // passed to the Object
506  //2. If the cursor is at the end of a non empty paragraph a paragraph
507  // break should be inserted. StarMath objects are character bound and
508  // no break should be inserted.
509  //3. If an selection is passed to a StarMath object, this object should
510  // not be activated. false should be returned then.
511  bool bStarMath = true;
512  bool bActivate = true;
513 
514  // set parent to get correct VisArea(in case of object needing parent printer)
515  uno::Reference < container::XChild > xChild( xRef.GetObject(), uno::UNO_QUERY );
516  if ( xChild.is() )
517  xChild->setParent( mxDoc->GetDocShell()->GetModel() );
518 
519  SvGlobalName aCLSID( xRef->getClassID() );
520  bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
521  if( IsSelection() )
522  {
523  if( bStarMath )
524  {
525  OUString aMathData;
526  GetSelectedText( aMathData, ParaBreakType::ToOnlyCR );
527 
528  if( !aMathData.isEmpty() && svt::EmbeddedObjectRef::TryRunningState( xRef.GetObject() ) )
529  {
530  uno::Reference < beans::XPropertySet > xSet( xRef->getComponent(), uno::UNO_QUERY );
531  if ( xSet.is() )
532  {
533  try
534  {
535  xSet->setPropertyValue("Formula", uno::makeAny( aMathData ) );
536  bActivate = false;
537  }
538  catch (const uno::Exception&)
539  {
540  }
541  }
542  }
543  }
544  DelRight();
545  }
546 
547  if ( !bStarMath )
548  SwFEShell::SplitNode( false, false );
549 
550  EnterSelFrameMode();
551 
552  const SvGlobalName* pName = nullptr;
553  SvGlobalName aObjClsId;
554  if (xRef.is())
555  {
556  aObjClsId = SvGlobalName(xRef.GetObject()->getClassID());
557  pName = &aObjClsId;
558  }
559  SwFlyFrameAttrMgr aFrameMgr( true, this, Frmmgr_Type::OLE, pName );
561 
562  SwRect aBound;
563  CalcBoundRect( aBound, aFrameMgr.GetAnchor() );
564 
565  //The Size should be suggested by the OLE server
566  MapMode aMapMode( MapUnit::MapTwip );
567  Size aSz = xRef.GetSize( &aMapMode );
568 
569  //Object size can be limited
570  if ( aSz.Width() > aBound.Width() )
571  {
572  //Always limit proportional.
573  aSz.setHeight( aSz.Height() * aBound.Width() / aSz.Width() );
574  aSz.setWidth( aBound.Width() );
575  }
576  aFrameMgr.SetSize( aSz );
577  SwFlyFrameFormat *pFormat = SwFEShell::InsertObject( xRef, &aFrameMgr.GetAttrSet() );
578 
579  // --> #i972#
580  if ( bStarMath && mxDoc->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ) )
581  AlignFormulaToBaseline( xRef.GetObject() );
582 
583  if (pFlyFrameFormat)
584  *pFlyFrameFormat = pFormat;
585 
586  if ( SotExchange::IsChart( aCLSID ) )
587  {
588  uno::Reference< embed::XEmbeddedObject > xEmbeddedObj = xRef.GetObject();
589  if ( xEmbeddedObj.is() )
590  {
591  bool bDisableDataTableDialog = false;
593  uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY );
594  if ( xProps.is() &&
595  ( xProps->getPropertyValue("DisableDataTableDialog") >>= bDisableDataTableDialog ) &&
596  bDisableDataTableDialog )
597  {
598  xProps->setPropertyValue("DisableDataTableDialog",
599  uno::makeAny( false ) );
600  xProps->setPropertyValue("DisableComplexChartTypes",
601  uno::makeAny( false ) );
602  uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
603  if ( xModifiable.is() )
604  {
605  xModifiable->setModified( true );
606  }
607  }
608  }
609  }
610 
611  EndAllAction();
612  GetView().AutoCaption(OLE_CAP, &aCLSID);
613 
614  SwRewriter aRewriter;
615 
616  if ( bStarMath )
617  aRewriter.AddRule(UndoArg1, SwResId(STR_MATH_FORMULA));
618  else if ( SotExchange::IsChart( aCLSID ) )
619  aRewriter.AddRule(UndoArg1, SwResId(STR_CHART));
620  else
621  aRewriter.AddRule(UndoArg1, SwResId(STR_OLE));
622 
623  EndUndo(SwUndoId::INSERT, &aRewriter);
624 
625  rEmbeddedObjectContainer.setUserAllowsLinkUpdate(bSaveUserAllowsLinkUpdate);
626 
627  return bActivate;
628 }
629 
630 // The current selected OLE object will be loaded with the
631 // verb into the server.
632 void SwWrtShell::LaunchOLEObj(sal_Int32 nVerb)
633 {
634  if ( GetCntType() != CNT_OLE ||
635  GetView().GetViewFrame()->GetFrame().IsInPlace() )
636  return;
637 
638  svt::EmbeddedObjectRef& xRef = GetOLEObject();
639  OSL_ENSURE( xRef.is(), "OLE not found" );
640 
641  // LOK: we don't want to handle any other embedded objects than
642  // charts, there are too many problems with eg. embedded spreadsheets
643  // (like it creates a separate view for the calc sheet)
644  if (comphelper::LibreOfficeKit::isActive() && !SotExchange::IsChart(xRef->getClassID()))
645  return;
646 
647  SfxInPlaceClient* pCli = GetView().FindIPClient( xRef.GetObject(), &GetView().GetEditWin() );
648  if ( !pCli )
649  pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xRef );
650 
651  static_cast<SwOleClient*>(pCli)->SetInDoVerb( true );
652 
653  CalcAndSetScale( xRef );
654  pCli->DoVerb( nVerb );
655 
656  static_cast<SwOleClient*>(pCli)->SetInDoVerb( false );
657  CalcAndSetScale( xRef );
658 }
659 
660 void SwWrtShell::MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset )
661 {
662  try
663  {
664  sal_Int32 nState = xObj->getCurrentState();
665  if ( nState == css::embed::EmbedStates::INPLACE_ACTIVE
666  || nState == css::embed::EmbedStates::UI_ACTIVE )
667  {
668  SfxInPlaceClient* pCli =
669  GetView().FindIPClient( xObj.GetObject(), &(GetView().GetEditWin()) );
670  if ( pCli )
671  {
672  tools::Rectangle aArea = pCli->GetObjArea();
673  aArea += rOffset;
674  pCli->SetObjArea( aArea );
675  }
676  }
677  }
678  catch (const uno::Exception&)
679  {
680  }
681 }
682 
684  const SwRect *pFlyPrtRect,
685  const SwRect *pFlyFrameRect,
686  const bool bNoTextFramePrtAreaChanged )
687 {
688  // Setting the scale of the client. This arises from the difference
689  // between the VisArea of the object and the ObjArea.
690  OSL_ENSURE( xObj.is(), "ObjectRef not valid" );
691 
692  sal_Int64 nAspect = xObj.GetViewAspect();
693  if ( nAspect == embed::Aspects::MSOLE_ICON )
694  return; // the replacement image is completely controlled by container in this case
695 
696  sal_Int64 nMisc = 0;
697  bool bLinkingChart = false;
698 
699  try
700  {
701  nMisc = xObj->getStatus( nAspect );
702 
703  // This can surely only be a non-active object, if desired they
704  // get the new size set as VisArea (StarChart).
705  if( embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE & nMisc )
706  {
707  // TODO/MBA: testing
708  SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
709  : GetAnyCurRect( CurRectType::FlyEmbeddedPrt, nullptr, xObj.GetObject() ));
710  if( !aRect.IsEmpty() )
711  {
712  // TODO/LEAN: getMapUnit can switch object to running state
713  // xObj.TryRunningState();
714 
715  MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
716 
717  // TODO/LATER: needs complete VisArea?!
718  Size aSize( OutputDevice::LogicToLogic(aRect.SVRect(), MapMode(MapUnit::MapTwip), MapMode(aUnit)).GetSize() );
719  awt::Size aSz;
720  aSz.Width = aSize.Width();
721  aSz.Height = aSize.Height();
722 
723  // Action 'setVisualAreaSize' doesn't have to turn on the
724  // modified state of the document, either.
725  bool bModified = false;
726  uno::Reference<util::XModifiable> xModifiable(xObj->getComponent(), uno::UNO_QUERY);
727  if (xModifiable.is())
728  bModified = xModifiable->isModified();
729  xObj->setVisualAreaSize( nAspect, aSz );
730  xModifiable.set(xObj->getComponent(), uno::UNO_QUERY);
731  if (xModifiable.is() && xModifiable->isModified() && !bModified)
732  xModifiable->setModified(bModified);
733 
734  // #i48419# - action 'UpdateReplacement' doesn't
735  // have to change the modified state of the document.
736  // This is only a workaround for the defect, that this action
737  // modifies a document after load, because unnecessarily the
738  // replacement graphic is updated, in spite of the fact that
739  // nothing has been changed.
740  // If the replacement graphic changes by this action, the document
741  // will be already modified via other mechanisms.
742  {
743  bool bResetEnableSetModified(false);
744  if ( GetDoc()->GetDocShell()->IsEnableSetModified() )
745  {
746  GetDoc()->GetDocShell()->EnableSetModified( false );
747  bResetEnableSetModified = true;
748  }
749 
750  //#i79576# don't destroy chart replacement images on load
751  //#i79578# don't request a new replacement image for charts to often
752  //a chart sends a modified call to the framework if it was changed
753  //thus the replacement update is already handled elsewhere
754  if ( !SotExchange::IsChart( xObj->getClassID() ) )
755  xObj.UpdateReplacement();
756 
757  if ( bResetEnableSetModified )
758  {
759  GetDoc()->GetDocShell()->EnableSetModified();
760  }
761  }
762  }
763 
764  // TODO/LATER: this is only a workaround,
765  uno::Reference< chart2::XChartDocument > xChartDocument( xObj->getComponent(), uno::UNO_QUERY );
766  bLinkingChart = ( xChartDocument.is() && !xChartDocument->hasInternalDataProvider() );
767  }
768  }
769  catch (const uno::Exception&)
770  {
771  // TODO/LATER: handle the error
772  return;
773  }
774 
775  SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
776  if ( !pCli )
777  {
778  if ( (embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY & nMisc)
779  || bLinkingChart
780  // --> OD #i117189# - refine condition for non-resizable objects
781  // non-resizable objects need to be set the size back by this method
782  || ( bNoTextFramePrtAreaChanged && nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
783  {
784  pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
785  }
786  else
787  return;
788  }
789 
790  // TODO/LEAN: getMapUnit can switch object to running state
791  // xObj.TryRunningState();
792 
793  awt::Size aSize;
794  try
795  {
796  aSize = xObj->getVisualAreaSize( nAspect );
797  }
798  catch (const embed::NoVisualAreaSizeException&)
799  {
800  OSL_FAIL("Can't get visual area size!" );
801  // the scaling will not be done
802  }
803  catch (const uno::Exception&)
804  {
805  // TODO/LATER: handle the error
806  OSL_FAIL("Can't get visual area size!" );
807  return;
808  }
809 
810  Size _aVisArea( aSize.Width, aSize.Height );
811 
812  Fraction aScaleWidth( 1, 1 );
813  Fraction aScaleHeight( 1, 1 );
814 
815  bool bUseObjectSize = false;
816 
817  // As long as there comes no reasonable size from the object,
818  // nothing can be scaled.
819  if( _aVisArea.Width() && _aVisArea.Height() )
820  {
821  const MapMode aTmp( MapUnit::MapTwip );
822  MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
823  _aVisArea = OutputDevice::LogicToLogic(_aVisArea, MapMode(aUnit), aTmp);
824  Size aObjArea;
825  if ( pFlyPrtRect )
826  aObjArea = pFlyPrtRect->SSize();
827  else
828  aObjArea = GetAnyCurRect( CurRectType::FlyEmbeddedPrt, nullptr, xObj.GetObject() ).SSize();
829 
830  // differ the aObjArea and _aVisArea by 1 Pixel then set new VisArea
831  tools::Long nX, nY;
832  SwSelPaintRects::Get1PixelInLogic( *this, &nX, &nY );
833  if( !( _aVisArea.Width() - nX <= aObjArea.Width() &&
834  _aVisArea.Width() + nX >= aObjArea.Width() &&
835  _aVisArea.Height()- nY <= aObjArea.Height()&&
836  _aVisArea.Height()+ nY >= aObjArea.Height() ))
837  {
838  if ( nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE )
839  {
840  // the object must not be scaled,
841  // the size stored in object must be used for restoring
842  bUseObjectSize = true;
843  }
844  else
845  {
846  aScaleWidth = Fraction( aObjArea.Width(), _aVisArea.Width() );
847  aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height());
848  }
849  }
850  }
851 
852  // Now is the favorable time to set the ObjArea.
853  // The Scaling must be considered.
854  SwRect aArea;
855  if ( pFlyPrtRect )
856  {
857  aArea = *pFlyPrtRect;
858  aArea += pFlyFrameRect->Pos();
859  }
860  else
861  {
862  aArea = GetAnyCurRect( CurRectType::FlyEmbeddedPrt, nullptr, xObj.GetObject() );
863  aArea.Pos() += GetAnyCurRect( CurRectType::FlyEmbedded, nullptr, xObj.GetObject() ).Pos();
864  }
865 
866  if ( bUseObjectSize )
867  {
868  // --> this moves non-resizable object so that when adding borders the baseline remains the same
869  const SwFlyFrameFormat *pFlyFrameFormat = dynamic_cast< const SwFlyFrameFormat * >( GetFlyFrameFormat() );
870  OSL_ENSURE( pFlyFrameFormat, "Could not find fly frame." );
871  if ( pFlyFrameFormat )
872  {
873  const Point &rPoint = pFlyFrameFormat->GetLastFlyFramePrtRectPos();
874  SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
875  : GetAnyCurRect( CurRectType::FlyEmbeddedPrt, nullptr, xObj.GetObject() ));
876  aArea += rPoint - aRect.Pos(); // adjust area by diff of printing area position in order to keep baseline alignment correct.
877  }
878  aArea.Width ( _aVisArea.Width() );
879  aArea.Height( _aVisArea.Height() );
880  RequestObjectResize( aArea, xObj.GetObject() );
881  }
882  else
883  {
884  aArea.Width ( tools::Long( aArea.Width() / pCli->GetScaleWidth() ) );
885  aArea.Height( tools::Long( aArea.Height() / pCli->GetScaleHeight() ) );
886  }
887 
888  pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight );
889 }
890 
892  const SwRect &rFrame )
893 {
894  SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin());
895  if ( !pCli )
896  new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
897  CalcAndSetScale( xObj, &rPrt, &rFrame );
898 }
899 
900 // Insert hard page break;
901 // Selections will be overwritten
902 void SwWrtShell::InsertPageBreak(const OUString *pPageDesc, const ::std::optional<sal_uInt16>& oPgNum )
903 {
904  if (!lcl_IsAllowed(this))
905  return;
906 
907  ResetCursorStack();
908  if( CanInsert() )
909  {
910  SwActContext aActContext(this);
912 
913  if ( !IsCursorInTable() )
914  {
915  if(HasSelection())
916  DelRight();
918  // delete the numbered attribute of the last line if the last line is empty
919  GetDoc()->ClearLineNumAttrs( *GetCursor()->GetPoint() );
920  }
921 
922  const SwPageDesc *pDesc = pPageDesc
923  ? FindPageDescByName( *pPageDesc, true ) : nullptr;
924  if( pDesc )
925  {
926  SwFormatPageDesc aDesc( pDesc );
927  aDesc.SetNumOffset( oPgNum );
928  SetAttrItem( aDesc );
929  }
930  else
931  SetAttrItem( SvxFormatBreakItem(SvxBreak::PageBefore, RES_BREAK) );
933  }
934  collectUIInformation("BREAK_PAGE", "parameter");
935 }
936 
937 // Insert hard page break;
938 // Selections will be overwritten
939 
941 {
942  if (!lcl_IsAllowed(this))
943  return;
944 
945  ResetCursorStack();
946  if( CanInsert() )
947  {
948  if(HasSelection())
949  DelRight();
950 
951  const sal_Unicode cIns = 0x0A;
952  SvxAutoCorrect* pACorr = lcl_IsAutoCorr();
953  if( pACorr )
954  AutoCorrect( *pACorr, cIns );
955  else
956  SwWrtShell::Insert( OUString( cIns ) );
957  }
958 }
959 
960 // Insert hard column break;
961 // Selections will be overwritten
962 
964 {
965  if (!lcl_IsAllowed(this))
966  return;
967 
968  SwActContext aActContext(this);
969  ResetCursorStack();
970  if( !CanInsert() )
971  return;
972 
974 
975  if ( !IsCursorInTable() )
976  {
977  if(HasSelection())
978  DelRight();
979  SwFEShell::SplitNode( false, false );
980  }
981  SetAttrItem(SvxFormatBreakItem(SvxBreak::ColumnBefore, RES_BREAK));
982 
984 }
985 
986 // Insert footnote
987 // rStr - optional footnote mark
988 
989 void SwWrtShell::InsertFootnote(const OUString &rStr, bool bEndNote, bool bEdit )
990 {
991  ResetCursorStack();
992  if( !CanInsert() )
993  return;
994 
995  if(HasSelection())
996  {
997  //collapse cursor to the end
998  if(!IsCursorPtAtEnd())
999  SwapPam();
1000  ClearMark();
1001  }
1002  SwPosition aPos = *GetCursor()->GetPoint();
1003  SwFormatFootnote aFootNote( bEndNote );
1004  if(!rStr.isEmpty())
1005  aFootNote.SetNumStr( rStr );
1006 
1007  SetAttrItem(aFootNote);
1008 
1009  if( bEdit )
1010  {
1011  // For editing the footnote text.
1012  Left(CRSR_SKIP_CHARS, false, 1, false );
1013  GotoFootnoteText();
1014  }
1015  m_aNavigationMgr.addEntry(aPos);
1016 }
1017 
1018 // SplitNode; also, because
1019 // - of deleting selected content;
1020 // - of reset of the Cursorstack if necessary.
1021 
1022 void SwWrtShell::SplitNode( bool bAutoFormat )
1023 {
1024  if (!lcl_IsAllowed(this))
1025  return;
1026 
1027  ResetCursorStack();
1028  if( !CanInsert() )
1029  return;
1030 
1031  SwActContext aActContext(this);
1032 
1033  m_rView.GetEditWin().FlushInBuffer();
1034  bool bHasSel = HasSelection();
1035  if( bHasSel )
1036  {
1037  StartUndo( SwUndoId::INSERT );
1038  DelRight();
1039  }
1040 
1041  SwFEShell::SplitNode( bAutoFormat );
1042  if( bHasSel )
1044 }
1045 
1046 // Turn on numbering
1047 // Parameter: Optional specification of a name for the named list;
1048 // this indicates a position if it is possible to convert them
1049 // into a number and less than nMaxRules.
1050 
1051 // To test the CharFormats at the numbering
1052 // external void SetNumChrFormat( SwWrtShell*, SwNumRules& );
1053 
1054 // -> #i40041#
1055 // Preconditions (as far as OD has figured out):
1056 // - <SwEditShell::HasNumber()> is false, if <bNum> is true
1057 // - <SwEditShell::HasBullet()> is false, if <bNum> is false
1058 // Behavior of method is determined by the current situation at the current
1059 // cursor position in the document.
1061 {
1062  // determine numbering rule found at current cursor position in the document.
1063  const SwNumRule* pCurRule = GetNumRuleAtCurrCursorPos();
1064 
1065  StartUndo(SwUndoId::NUMORNONUM);
1066 
1067  const SwNumRule * pNumRule = pCurRule;
1068 
1069  // - activate outline rule respectively turning on outline rule for
1070  // current text node. But, only for turning on a numbering (<bNum> == true).
1071  // - overwrite found numbering rule at current cursor position, if
1072  // no numbering rule can be retrieved from the paragraph style.
1073  bool bContinueFoundNumRule( false );
1074  bool bActivateOutlineRule( false );
1075  int nActivateOutlineLvl( MAXLEVEL ); // only relevant, if <bActivateOutlineRule> == true
1077  if ( pColl )
1078  {
1079  // retrieve numbering rule at paragraph
1080  // style, which is found at current cursor position in the document.
1081  SwNumRule* pCollRule = mxDoc->FindNumRulePtr(pColl->GetNumRule().GetValue());
1082  // #125993# - The outline numbering rule isn't allowed
1083  // to be derived from a parent paragraph style to a derived one.
1084  // Thus check, if the found outline numbering rule is directly
1085  // set at the paragraph style <pColl>. If not, set <pCollRule> to NULL
1086  if ( pCollRule && pCollRule == GetDoc()->GetOutlineNumRule() )
1087  {
1088  const SwNumRule* pDirectCollRule =
1089  mxDoc->FindNumRulePtr(pColl->GetNumRule( false ).GetValue());
1090  if ( !pDirectCollRule )
1091  {
1092  pCollRule = nullptr;
1093  }
1094  }
1095 
1096  if ( !pCollRule )
1097  {
1098  pNumRule = pCollRule;
1099  }
1100  // no activation or continuation of outline numbering in Writer/Web document
1101  else if ( bNum &&
1102  !dynamic_cast<SwWebDocShell*>(GetDoc()->GetDocShell()) &&
1103  pCollRule == GetDoc()->GetOutlineNumRule() )
1104  {
1105  if ( pNumRule == pCollRule )
1106  {
1107  // check, if text node at current cursor positioned is counted.
1108  // If not, let it been counted. Then it has to be checked,
1109  // of the outline numbering has to be activated or continued.
1110  SwTextNode const*const pTextNode = sw::GetParaPropsNode(
1111  *GetLayout(), GetCursor()->GetPoint()->nNode);
1112  if ( pTextNode && !pTextNode->IsCountedInList() )
1113  {
1114  // check, if numbering of the outline level of the paragraph
1115  // style is active. If not, activate this outline level.
1116  nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
1117  OSL_ENSURE( pColl->IsAssignedToListLevelOfOutlineStyle(),
1118  "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
1119  if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&
1120  pCollRule->Get( o3tl::narrowing<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
1121  == SVX_NUM_NUMBER_NONE )
1122  {
1123  // activate outline numbering
1124  bActivateOutlineRule = true;
1125  }
1126  else
1127  {
1128  // turning on outline numbering at current cursor position
1129  bContinueFoundNumRule = true;
1130  }
1131  }
1132  else
1133  {
1134  // #i101234#
1135  // activate outline numbering, because from the precondition
1136  // it's known, that <SwEdit::HasNumber()> == false
1137  bActivateOutlineRule = true;
1138  nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
1139  }
1140  }
1141  else if ( !pNumRule )
1142  {
1143  // #i101234#
1144  // Check, if corresponding list level of the outline numbering
1145  // has already a numbering format set.
1146  nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
1147  if ( pCollRule->Get( o3tl::narrowing<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
1148  == SVX_NUM_NUMBER_NONE )
1149  {
1150  // activate outline numbering, because from the precondition
1151  // it's known, that <SwEdit::HasNumber()> == false
1152  bActivateOutlineRule = true;
1153  }
1154  else
1155  {
1156  // turning on outline numbering at current cursor position
1157  bContinueFoundNumRule = true;
1158  }
1159  }
1160  else
1161  {
1162  // check, if numbering of the outline level of the paragraph
1163  // style is active. If not, activate this outline level.
1164  nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
1165  OSL_ENSURE( pColl->IsAssignedToListLevelOfOutlineStyle(),
1166  "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
1167  if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&
1168  pCollRule->Get( o3tl::narrowing<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
1169  == SVX_NUM_NUMBER_NONE )
1170  {
1171  // activate outline numbering
1172  bActivateOutlineRule = true;
1173  }
1174  else
1175  {
1176  // turning on outline numbering at current cursor position
1177  bContinueFoundNumRule = true;
1178  }
1179  }
1180  pNumRule = pCollRule;
1181  }
1182  }
1183 
1184  // Only automatic numbering/bullet rules should be changed.
1185  // Note: The outline numbering rule is also an automatic one. It's only
1186  // changed, if it has to be activated.
1187  if ( pNumRule )
1188  {
1189  if ( !pNumRule->IsAutoRule() )
1190  {
1191  pNumRule = nullptr;
1192  }
1193  else if ( pNumRule == GetDoc()->GetOutlineNumRule() &&
1194  !bActivateOutlineRule && !bContinueFoundNumRule )
1195  {
1196  pNumRule = nullptr;
1197  }
1198  }
1199 
1200  // Search for a previous numbering/bullet rule to continue it.
1201  OUString sContinuedListId;
1202  if ( !pNumRule )
1203  {
1204  pNumRule = GetDoc()->SearchNumRule( *GetCursor()->GetPoint(),
1205  false, bNum, false, 0,
1206  sContinuedListId, GetLayout() );
1207  bContinueFoundNumRule = pNumRule != nullptr;
1208  }
1209 
1210  if (pNumRule)
1211  {
1212  SwNumRule aNumRule(*pNumRule);
1213 
1214  // do not change found numbering/bullet rule, if it should only be continued.
1215  if ( !bContinueFoundNumRule )
1216  {
1217  SwTextNode const*const pTextNode = sw::GetParaPropsNode(
1218  *GetLayout(), GetCursor()->GetPoint()->nNode);
1219 
1220  if (pTextNode)
1221  {
1222  // use above retrieve outline level, if outline numbering has to be activated.
1223  int nLevel = bActivateOutlineRule
1224  ? nActivateOutlineLvl
1225  : pTextNode->GetActualListLevel();
1226 
1227  if (nLevel < 0)
1228  nLevel = 0;
1229 
1230  if (nLevel >= MAXLEVEL)
1231  nLevel = MAXLEVEL - 1;
1232 
1233  SwNumFormat aFormat(aNumRule.Get(o3tl::narrowing<sal_uInt16>(nLevel)));
1234 
1235  if (bNum)
1237  else
1238  {
1239  // #i63395# Only apply user defined default bullet font
1241  {
1242  const vcl::Font* pFnt = &numfunc::GetDefBulletFont();
1243  aFormat.SetBulletFont( pFnt );
1244  }
1245  aFormat.SetBulletChar( numfunc::GetBulletChar(static_cast<sal_uInt8>(nLevel)));
1246  aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1247  // #i93908# clear suffix for bullet lists
1248  aFormat.SetPrefix(OUString());
1249  aFormat.SetSuffix(OUString());
1250  }
1251  aNumRule.Set(o3tl::narrowing<sal_uInt16>(nLevel), aFormat);
1252  }
1253  }
1254 
1255  // reset indent attribute on applying list style
1256  SetCurNumRule( aNumRule, false, sContinuedListId, true );
1257  }
1258  else
1259  {
1260  // #i95907#
1261  const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
1263  SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode );
1264  // Append the character template at the numbering.
1265  SwCharFormat* pChrFormat;
1266  SwDocShell* pDocSh = GetView().GetDocShell();
1267  // #i63395#
1268  // Only apply user defined default bullet font
1271  : nullptr;
1272 
1273  if (bNum)
1274  {
1275  pChrFormat = GetCharFormatFromPool( RES_POOLCHR_NUM_LEVEL );
1276  }
1277  else
1278  {
1279  pChrFormat = GetCharFormatFromPool( RES_POOLCHR_BULLET_LEVEL );
1280  }
1281 
1282  const SwTextNode *const pTextNode = sw::GetParaPropsNode(*GetLayout(),
1283  GetCursor()->GetPoint()->nNode);
1284  const SwTwips nWidthOfTabs = pTextNode
1285  ? pTextNode->GetWidthOfLeadingTabs()
1286  : 0;
1287  GetDoc()->getIDocumentContentOperations().RemoveLeadingWhiteSpace( *GetCursor()->GetPoint() );
1288 
1289  const bool bHtml = dynamic_cast<SwWebDocShell*>( pDocSh ) != nullptr;
1290  const bool bRightToLeft = IsInRightToLeftText();
1291  for( sal_uInt8 nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
1292  {
1293  SwNumFormat aFormat( aNumRule.Get( nLvl ) );
1294  aFormat.SetCharFormat( pChrFormat );
1295 
1296  if (! bNum)
1297  {
1298  // #i63395#
1299  // Only apply user defined default bullet font
1300  if ( pFnt )
1301  {
1302  aFormat.SetBulletFont( pFnt );
1303  }
1304  aFormat.SetBulletChar( numfunc::GetBulletChar(nLvl) );
1305  aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1306  // #i93908# clear suffix for bullet lists
1307  aFormat.SetPrefix(OUString());
1308  aFormat.SetSuffix(OUString());
1309  }
1310 
1311  // #i95907#
1312  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1313  {
1314  if(bHtml && nLvl)
1315  {
1316  // 1/2" for HTML
1317  aFormat.SetAbsLSpace(nLvl * 720);
1318  }
1319  else if ( nWidthOfTabs > 0 )
1320  {
1321  aFormat.SetAbsLSpace(nWidthOfTabs + nLvl * 720);
1322  }
1323  }
1324 
1325  // #i38904# Default alignment for
1326  // numbering/bullet should be rtl in rtl paragraph:
1327  if ( bRightToLeft )
1328  {
1329  aFormat.SetNumAdjust( SvxAdjust::Right );
1330  }
1331 
1332  aNumRule.Set( nLvl, aFormat );
1333  }
1334 
1335  // #i95907#
1336  if ( pTextNode &&
1337  ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1338  {
1339 
1340  const SwTwips nTextNodeIndent = pTextNode->GetAdditionalIndentForStartingNewList();
1341  if ( ( nTextNodeIndent + nWidthOfTabs ) != 0 )
1342  {
1343  // #i111172#/fdo#85666
1344  // If text node is already inside a list, assure that the indents
1345  // are the same. Thus, adjust the indent change value by subtracting
1346  // indents of to be applied list style.
1347  SwTwips nIndentChange = nTextNodeIndent + nWidthOfTabs;
1348  if ( pTextNode->GetNumRule() )
1349  {
1350  int nLevel = pTextNode->GetActualListLevel();
1351 
1352  if (nLevel < 0)
1353  nLevel = 0;
1354 
1355  if (nLevel >= MAXLEVEL)
1356  nLevel = MAXLEVEL - 1;
1357 
1358  const SwNumFormat& aFormat( aNumRule.Get( nLevel ) );
1359  if ( aFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1360  {
1361  nIndentChange -= aFormat.GetIndentAt() + aFormat.GetFirstLineIndent();
1362  }
1363  }
1364  aNumRule.ChangeIndent( nIndentChange );
1365  }
1366  }
1367  // reset indent attribute on applying list style
1368  // start new list
1369  SetCurNumRule( aNumRule, true, OUString(), true );
1370  }
1371 
1373 }
1374 // <- #i40041#
1375 
1377 {
1378  NumOrBulletOn(true);
1379 }
1380 
1382 {
1383  const SwNumRule * pCurNumRule = GetNumRuleAtCurrCursorPos();
1384 
1385  if (!pCurNumRule)
1386  return;
1387 
1388  if (pCurNumRule->IsOutlineRule())
1389  {
1390  SwNumRule aNumRule(*pCurNumRule);
1391 
1392  SwTextNode * pTextNode =
1393  sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->nNode);
1394 
1395  if (pTextNode)
1396  {
1397  int nLevel = pTextNode->GetActualListLevel();
1398 
1399  if (nLevel < 0)
1400  nLevel = 0;
1401 
1402  if (nLevel >= MAXLEVEL)
1403  nLevel = MAXLEVEL - 1;
1404 
1405  SwNumFormat aFormat(aNumRule.Get(o3tl::narrowing<sal_uInt16>(nLevel)));
1406 
1408  aNumRule.Set(nLevel, aFormat);
1409 
1410  // no start or continuation of a list - the outline style is only changed.
1411  SetCurNumRule( aNumRule, false );
1412  }
1413  }
1414  else
1415  {
1416  DelNumRules();
1417  }
1418 
1419  // #126346# - Cursor can not be anymore in front of
1420  // a label, because numbering/bullet is switched off.
1421  SetInFrontOfLabel( false );
1422 }
1423 // <- #i29560#
1424 
1425 // Request Default-Bulletlist
1426 
1428 {
1429  NumOrBulletOn(false);
1430 }
1431 
1433 {
1434  // ContentType cannot be determined within a Start-/EndAction.
1435  // Because there is no invalid value TEXT will be returned.
1436  // The value does not matter, it may be updated in EndAction anyway.
1437 
1438  if (ActionPend())
1439  return IsSelFrameMode() ? SelectionType::Frame : SelectionType::Text;
1440 
1441  SwView &_rView = const_cast<SwView&>(GetView());
1442  if (_rView.GetPostItMgr() && _rView.GetPostItMgr()->HasActiveSidebarWin() )
1443  return SelectionType::PostIt;
1444 
1445  // Inserting a frame is not a DrawMode
1446  SelectionType nCnt;
1447  if ( !_rView.GetEditWin().IsFrameAction() &&
1448  (IsObjSelected() || (_rView.IsDrawMode() && !IsFrameSelected()) ))
1449  {
1450  if (GetDrawView()->IsTextEdit())
1452  else
1453  {
1454  if (GetView().IsFormMode()) // Only Form selected
1455  nCnt = SelectionType::DbForm;
1456  else
1457  nCnt = SelectionType::DrawObject; // Any draw object
1458 
1459  if (_rView.IsBezierEditMode())
1460  nCnt |= SelectionType::Ornament;
1461  else if( GetDrawView()->GetContext() == SdrViewContext::Media )
1462  nCnt |= SelectionType::Media;
1463 
1464  if (svx::checkForSelectedCustomShapes( GetDrawView(), true /* bOnlyExtruded */ ))
1465  {
1467  }
1468 
1469  if (svx::checkForSelectedFontWork( GetDrawView() ))
1470  {
1471  nCnt |= SelectionType::FontWork;
1472  }
1473  }
1474 
1475  return nCnt;
1476  }
1477 
1478  nCnt = static_cast<SelectionType>(GetCntType());
1479 
1480  if ( IsFrameSelected() )
1481  {
1482  if (_rView.IsDrawMode())
1483  _rView.LeaveDrawCreate(); // clean up (Bug #45639)
1484  if ( !(nCnt & (SelectionType::Graphic | SelectionType::Ole)) )
1485  return SelectionType::Frame;
1486  }
1487 
1488  if ( IsCursorInTable() )
1489  nCnt |= SelectionType::Table;
1490 
1491  if ( IsTableMode() )
1492  {
1494  SwTable::SearchType eTableSel = GetEnhancedTableSelection();
1495  if ( eTableSel == SwTable::SEARCH_ROW )
1496  nCnt |= SelectionType::TableRow;
1497  else if ( eTableSel == SwTable::SEARCH_COL )
1498  nCnt |= SelectionType::TableCol;
1499  }
1500 
1501  // Do not pop up numbering toolbar, if the text node has a numbering of type SVX_NUM_NUMBER_NONE.
1502  const SwNumRule* pNumRule = GetNumRuleAtCurrCursorPos();
1503  if ( pNumRule )
1504  {
1505  const SwTextNode* pTextNd =
1506  sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->nNode);
1507 
1508  if ( pTextNd && pTextNd->IsInList() )
1509  {
1510  int nLevel = pTextNd->GetActualListLevel();
1511 
1512  if (nLevel < 0)
1513  nLevel = 0;
1514 
1515  if (nLevel >= MAXLEVEL)
1516  nLevel = MAXLEVEL - 1;
1517 
1518  const SwNumFormat& rFormat = pNumRule->Get(nLevel);
1519  if ( SVX_NUM_NUMBER_NONE != rFormat.GetNumberingType() )
1520  nCnt |= SelectionType::NumberList;
1521  }
1522  }
1523 
1524  return nCnt;
1525 }
1526 
1527 // Find the text collection with the name rCollname
1528 // Returns: Pointer at the collection or 0, if no
1529 // text collection with this name exists, or
1530 // this is a default template.
1531 
1532 SwTextFormatColl *SwWrtShell::GetParaStyle(const OUString &rCollName, GetStyle eCreate )
1533 {
1534  SwTextFormatColl* pColl = FindTextFormatCollByName( rCollName );
1535  if( !pColl && GETSTYLE_NOCREATE != eCreate )
1536  {
1538  if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
1539  pColl = GetTextCollFromPool( nId );
1540  }
1541  return pColl;
1542 }
1543 
1544 // Find the text collection with the name rCollname
1545 // Returns: Pointer at the collection or 0, if no
1546 // character template with this name exists, or
1547 // this is a default template or template is automatic.
1548 
1549 SwCharFormat *SwWrtShell::GetCharStyle(const OUString &rFormatName, GetStyle eCreate )
1550 {
1551  SwCharFormat* pFormat = FindCharFormatByName( rFormatName );
1552  if( !pFormat && GETSTYLE_NOCREATE != eCreate )
1553  {
1555  if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
1556  pFormat = static_cast<SwCharFormat*>(GetFormatFromPool( nId ));
1557  }
1558  return pFormat;
1559 }
1560 
1561 // Find the table format with the name rFormatname
1562 // Returns: Pointer at the collection or 0, if no
1563 // frame format with this name exists or
1564 // this is a default format or the format is automatic.
1565 
1566 SwFrameFormat *SwWrtShell::GetTableStyle(std::u16string_view rFormatName)
1567 {
1568  for( size_t i = GetTableFrameFormatCount(); i; )
1569  {
1570  SwFrameFormat *pFormat = &GetTableFrameFormat( --i );
1571  if( !pFormat->IsDefault() &&
1572  pFormat->GetName() == rFormatName && IsUsed( *pFormat ) )
1573  return pFormat;
1574  }
1575  return nullptr;
1576 }
1577 
1579  SwPaM* pPaM = GetCursor();
1580  m_aNavigationMgr.addEntry(*pPaM->GetPoint());
1581 }
1582 
1583 // Applying templates
1584 
1585 void SwWrtShell::SetPageStyle(const OUString &rCollName)
1586 {
1587  if( !SwCursorShell::HasSelection() && !IsSelFrameMode() && !IsObjSelected() )
1588  {
1589  SwPageDesc* pDesc = FindPageDescByName( rCollName, true );
1590  if( pDesc )
1591  ChgCurPageDesc( *pDesc );
1592  }
1593 }
1594 
1595 // Access templates
1596 
1597 OUString const & SwWrtShell::GetCurPageStyle() const
1598 {
1599  return GetPageDesc(GetCurPageDesc( false/*bCalcFrame*/ )).GetName();
1600 }
1601 
1602 // Change the current template referring to the existing change.
1603 
1605 {
1607 
1608  // Default cannot be changed
1609  if(pColl && !pColl->IsDefault())
1610  {
1611  FillByEx(pColl);
1612  // Also apply the template to remove hard attribute assignment.
1613  SetTextFormatColl(pColl);
1614  }
1615 }
1616 
1617 void SwWrtShell::AutoUpdatePara(SwTextFormatColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM )
1618 {
1619  SwPaM* pCursor = pPaM ? pPaM : GetCursor( );
1620  SfxItemSet aCoreSet(
1621  GetAttrPool(),
1622  svl::Items<
1626  SID_ATTR_TABSTOP_DEFAULTS,SID_ATTR_TABSTOP_OFFSET,
1627  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
1628  SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
1629  SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM>);
1630  GetPaMAttr( pCursor, aCoreSet );
1631  bool bReset = false;
1632  SfxItemIter aParaIter( aCoreSet );
1633  for (auto pParaItem = aParaIter.GetCurItem(); pParaItem; pParaItem = aParaIter.NextItem())
1634  {
1635  if(!IsInvalidItem(pParaItem))
1636  {
1637  sal_uInt16 nWhich = pParaItem->Which();
1638  if(SfxItemState::SET == aCoreSet.GetItemState(nWhich) &&
1639  SfxItemState::SET == rStyleSet.GetItemState(nWhich))
1640  {
1641  aCoreSet.ClearItem(nWhich);
1642  bReset = true;
1643  }
1644  }
1645  }
1646  StartAction();
1647  if(bReset)
1648  {
1649  ResetAttr({}, pCursor);
1650  SetAttrSet(aCoreSet, SetAttrMode::DEFAULT, pCursor);
1651  }
1652  mxDoc->ChgFormat(*pColl, rStyleSet );
1653  EndAction();
1654 }
1655 
1656 void SwWrtShell::AutoUpdateFrame( SwFrameFormat* pFormat, const SfxItemSet& rStyleSet )
1657 {
1658  StartAction();
1659 
1660  ResetFlyFrameAttr( &rStyleSet );
1661  pFormat->SetFormatAttr( rStyleSet );
1662 
1663  EndAction();
1664 }
1665 
1667 {
1668  ResetCursorStack();
1669  if(!CanInsert())
1670  return;
1671 
1672  bool bStarted = false;
1673  SwRewriter aRewriter;
1674 
1675  if(HasSelection())
1676  {
1677  // Only parentheses here, because the regular insert
1678  // is already clipped to the editshell
1679  StartAllAction();
1680 
1681  OUString aTmpStr1 = SwResId(STR_START_QUOTE) +
1682  GetSelText() +
1683  SwResId(STR_END_QUOTE);
1684  OUString aTmpStr3 = SwResId(STR_START_QUOTE) +
1685  OUStringChar(cChar) +
1686  SwResId(STR_END_QUOTE);
1687  aRewriter.AddRule( UndoArg1, aTmpStr1 );
1688  aRewriter.AddRule( UndoArg2, SwResId(STR_YIELDS) );
1689  aRewriter.AddRule( UndoArg3, aTmpStr3 );
1690 
1691  StartUndo( SwUndoId::REPLACE, &aRewriter );
1692  bStarted = true;
1693  DelRight();
1694  }
1695  SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar );
1696 
1697  if(bStarted)
1698  {
1699  EndAllAction();
1700  EndUndo( SwUndoId::REPLACE, &aRewriter );
1701  }
1702 }
1703 
1704 // Some kind of controlled copy ctor
1705 
1707  : SwFEShell(rSh, _pWin)
1708  , m_rView(rShell)
1709  , m_aNavigationMgr(*this)
1710 {
1712  CurrShell aCurr( this );
1713 
1714  SetSfxViewShell( static_cast<SfxViewShell *>(&rShell) );
1715  SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
1716 
1717  // place the cursor on the first field...
1718  IFieldmark *pBM = nullptr;
1719  if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=nullptr ) {
1720  GotoFieldmark(pBM);
1721  }
1722 }
1723 
1725  const SwViewOption *pViewOpt )
1726  : SwFEShell(rDoc, _pWin, pViewOpt)
1727  , m_rView(rShell)
1728  , m_aNavigationMgr(*this)
1729 {
1731  CurrShell aCurr( this );
1732  SetSfxViewShell( static_cast<SfxViewShell *>(&rShell) );
1733  SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
1734 
1735  // place the cursor on the first field...
1736  IFieldmark *pBM = nullptr;
1737  if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=nullptr ) {
1738  GotoFieldmark(pBM);
1739  }
1740 }
1741 
1743 {
1744  CurrShell aCurr( this );
1745  while(IsModePushed())
1746  PopMode();
1747  while(PopCursor(false))
1748  ;
1750 }
1751 
1753 {
1754  bool bRet = SwCursorShell::Pop(eDelete);
1755  if( bRet && IsSelection() )
1756  {
1757  if (!IsAddMode())
1758  {
1761  }
1762  }
1763  return bRet;
1764 }
1765 
1767 {
1768  if(IsSelFrameMode())
1769  {
1770  return false;
1771  }
1772 
1773  if(IsObjSelected())
1774  {
1775  return false;
1776  }
1777 
1778  if(GetView().GetDrawFuncPtr())
1779  {
1780  return false;
1781  }
1782 
1783  if(GetView().GetPostItMgr()->GetActiveSidebarWin())
1784  {
1785  return false;
1786  }
1787 
1788  return true;
1789 }
1790 
1791 void SwWrtShell::ChgDBData(const SwDBData& aDBData)
1792 {
1793  SwEditShell::ChgDBData(aDBData);
1794  //notify the db-beamer if available
1796 }
1797 
1798 OUString SwWrtShell::GetSelDescr() const
1799 {
1800  OUString aResult;
1801 
1802  SelectionType nSelType = GetSelectionType();
1803  switch (nSelType)
1804  {
1806  aResult = SwResId(STR_GRAPHIC);
1807 
1808  break;
1809  case SelectionType::Frame:
1810  {
1811  const SwFrameFormat * pFrameFormat = GetSelectedFrameFormat();
1812 
1813  if (pFrameFormat)
1814  aResult = pFrameFormat->GetDescription();
1815  }
1816  break;
1818  {
1819  aResult = SwResId(STR_DRAWING_OBJECTS);
1820  }
1821  break;
1822  default:
1823  if (mxDoc)
1824  aResult = GetCursorDescr();
1825  }
1826 
1827  return aResult;
1828 }
1829 
1831 {
1833  //#i115062# invalidate meta character slot
1835 }
1836 
1838 {
1841 }
1842 
1843 // Switch on/off header or footer of a page style - if an empty name is
1844 // given all styles are changed
1845 
1847  std::u16string_view rStyleName, bool bHeader, bool bOn, bool bShowWarning)
1848 {
1849  SdrView *const pSdrView = GetDrawView();
1850  if (pSdrView && pSdrView->IsTextEdit())
1851  { // tdf#107474 deleting header may delete active drawing object
1852  pSdrView->SdrEndTextEdit(true);
1853  }
1855  StartAllAction();
1856  StartUndo( SwUndoId::HEADER_FOOTER ); // #i7983#
1857  bool bExecute = true;
1858  bool bCursorSet = false;
1859  for( size_t nFrom = 0, nTo = GetPageDescCnt();
1860  nFrom < nTo; ++nFrom )
1861  {
1862  SwPageDesc aDesc( GetPageDesc( nFrom ));
1863  OUString sTmp(aDesc.GetName());
1864  if( rStyleName.empty() || rStyleName == sTmp )
1865  {
1866  bool bChgd = false;
1867 
1868  if( bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() &&
1869  ( (bHeader && aDesc.GetMaster().GetHeader().IsActive()) ||
1870  (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) ) )
1871  {
1872  bShowWarning = false;
1873  //Actions have to be closed while the dialog is showing
1874  EndAllAction();
1875 
1876  weld::Window* pParent = GetView().GetFrameWeld();
1877  short nResult;
1878  if (bHeader) {
1879  nResult = DeleteHeaderDialog(pParent).run();
1880  } else {
1881  nResult = DeleteFooterDialog(pParent).run();
1882  }
1883 
1884  bExecute = nResult == RET_YES;
1885  StartAllAction();
1886  if (nResult == RET_YES)
1888  }
1889  if( bExecute )
1890  {
1891  bChgd = true;
1892  SwFrameFormat &rMaster = aDesc.GetMaster();
1893  if(bHeader)
1894  rMaster.SetFormatAttr( SwFormatHeader( bOn ));
1895  else
1896  rMaster.SetFormatAttr( SwFormatFooter( bOn ));
1897  if( bOn )
1898  {
1900  SvxULSpaceItem aUL(bHeader ? 0 : constTwips_5mm, bHeader ? constTwips_5mm : 0, RES_UL_SPACE );
1901  SwFrameFormat* pFormat = bHeader ?
1902  const_cast<SwFrameFormat*>(rMaster.GetHeader().GetHeaderFormat()) :
1903  const_cast<SwFrameFormat*>(rMaster.GetFooter().GetFooterFormat());
1904  pFormat->SetFormatAttr( aUL );
1905  XFillStyleItem aFill(drawing::FillStyle_NONE);
1906  pFormat->SetFormatAttr(aFill);
1907  }
1908  }
1909  if( bChgd )
1910  {
1911  ChgPageDesc( nFrom, aDesc );
1912 
1913  if( !bCursorSet && bOn )
1914  {
1915  if ( !IsHeaderFooterEdit() )
1917  bCursorSet = SetCursorInHdFt(
1918  rStyleName.empty() ? SIZE_MAX : nFrom,
1919  bHeader );
1920  }
1921  }
1922  }
1923  }
1924  EndUndo( SwUndoId::HEADER_FOOTER ); // #i7983#
1925  EndAllAction();
1926 }
1927 
1929 {
1930  SwViewShell::SetShowHeaderFooterSeparator( eControl, bShow );
1931  if ( !bShow )
1933 }
1934 
1935 void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq)
1936 {
1937  SwPostItField* pPostIt = dynamic_cast<SwPostItField*>(rFieldMgr.GetCurField());
1938  bool bNew = !(pPostIt && pPostIt->GetTyp()->Which() == SwFieldIds::Postit);
1939  if (bNew || GetView().GetPostItMgr()->IsAnswer())
1940  {
1941  const SvxPostItAuthorItem* pAuthorItem = rReq.GetArg<SvxPostItAuthorItem>(SID_ATTR_POSTIT_AUTHOR);
1942  OUString sAuthor;
1943  if ( pAuthorItem )
1944  sAuthor = pAuthorItem->GetValue();
1945  else
1946  {
1947  std::size_t nAuthor = SW_MOD()->GetRedlineAuthor();
1948  sAuthor = SW_MOD()->GetRedlineAuthor(nAuthor);
1949  }
1950 
1951  const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT);
1952  OUString sText;
1953  if ( pTextItem )
1954  sText = pTextItem->GetValue();
1955 
1956  // If we have a text already registered for answer, use that
1957  if (GetView().GetPostItMgr()->IsAnswer() && !GetView().GetPostItMgr()->GetAnswerText().isEmpty())
1958  {
1959  sText = GetView().GetPostItMgr()->GetAnswerText();
1960  GetView().GetPostItMgr()->RegisterAnswerText(OUString());
1961  }
1962 
1963  if ( HasSelection() && !IsTableMode() )
1964  {
1965  KillPams();
1966  }
1967 
1968  // #i120513# Inserting a comment into an autocompletion crashes
1969  // --> suggestion has to be removed before
1971 
1972  SwInsertField_Data aData(SwFieldTypesEnum::Postit, 0, sAuthor, sText, 0);
1973 
1974  if (IsSelFrameMode())
1975  {
1976  SwFlyFrame* pFly = GetSelectedFlyFrame();
1977 
1978  // Remember the anchor of the selected object before deletion.
1979  std::unique_ptr<SwPosition> pAnchor;
1980  if (pFly)
1981  {
1982  SwFrameFormat* pFormat = pFly->GetFormat();
1983  if (pFormat)
1984  {
1985  RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId();
1986  if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR) && pFormat->GetAnchor().GetContentAnchor())
1987  {
1988  pAnchor.reset(new SwPosition(*pFormat->GetAnchor().GetContentAnchor()));
1989  }
1990  }
1991  }
1992 
1993  // A frame is selected, end frame selection.
1994  EnterStdMode();
1995  GetView().AttrChangedNotify(nullptr);
1996 
1997  // Set up text selection, so the anchor of the frame will be the anchor of the
1998  // comment.
1999  if (pFly)
2000  {
2001  *GetCurrentShellCursor().GetPoint() = *pAnchor;
2002  SwFrameFormat* pFormat = pFly->GetFormat();
2003  if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR)
2004  {
2005  Right(CRSR_SKIP_CELLS, /*bSelect=*/true, 1, /*bBasicCall=*/false, /*bVisual=*/true);
2006  }
2007  else if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR)
2008  {
2009  aData.m_pAnnotationRange.reset(new SwPaM(*GetCurrentShellCursor().Start(),
2010  *GetCurrentShellCursor().End()));
2011  }
2012  }
2013  }
2014 
2015  rFieldMgr.InsertField( aData );
2016 
2017  Push();
2019  pPostIt = static_cast<SwPostItField*>(rFieldMgr.GetCurField());
2020  Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore cursor position
2021  }
2022 
2023  // Client has disabled annotations rendering, no need to
2024  // focus the postit field
2026  return;
2027 
2028  if (pPostIt)
2029  {
2031  if(auto pFormat = pType->FindFormatForField(pPostIt))
2032  pFormat->Broadcast( SwFormatFieldHint( nullptr, SwFormatFieldHintWhich::FOCUS, &GetView() ) );
2033  }
2034 }
2036 {
2037  const SwOutlineNodes& rOutlineNodes = GetDoc()->GetNodes().GetOutLineNds();
2038  const SwNode* pOutlineNode = rOutlineNodes[nPos];
2039 
2040  // no layout frame means outline folding is set to include sub levels and the outline node has
2041  // a parent outline node with outline content visible attribute false (folded outline content)
2042  if (!pOutlineNode->GetTextNode()->getLayoutFrame(nullptr))
2043  return false;
2044 
2045  // try the next node to determine if this outline node has visible content
2046  SwNodeIndex aIdx(*pOutlineNode, +1);
2047  if (&aIdx.GetNode() == &aIdx.GetNodes().GetEndOfContent()) // end of regular content
2048  return false;
2049 
2050  if (aIdx.GetNode().IsTextNode())
2051  {
2052  // sublevels treated as outline content
2053  // If next node (aIdx) doesn't have a layout frame
2054  // then this outline node does not have visible outline content.
2055  // sublevels NOT treated as outline content
2056  // If the next node (aIdx) is the next outline node
2057  // then return the outline content visible attribute value.
2059  nPos + 1 < rOutlineNodes.size() &&
2060  rOutlineNodes[nPos + 1] == &aIdx.GetNode())
2061  return GetAttrOutlineContentVisible(nPos);
2062 
2063  return aIdx.GetNode().GetTextNode()->getLayoutFrame(nullptr);
2064  }
2065 
2066  return true;
2067 }
2068 
2069 void SwWrtShell::MakeOutlineContentVisible(const size_t nPos, bool bMakeVisible)
2070 {
2071  const SwNodes& rNodes = GetNodes();
2072  const SwOutlineNodes& rOutlineNodes = rNodes.GetOutLineNds();
2073 
2074  SwNode* pSttNd = rOutlineNodes[nPos];
2075 
2076  // determine end node
2077  SwNode* pEndNd = &rNodes.GetEndOfContent();
2078  if (rOutlineNodes.size() > nPos + 1)
2079  pEndNd = rOutlineNodes[nPos + 1];
2080 
2082  {
2083  // get the last outline node to include (iPos)
2084  int nLevel = pSttNd->GetTextNode()->GetAttrOutlineLevel();
2085  SwOutlineNodes::size_type iPos = nPos;
2086  while (++iPos < rOutlineNodes.size() &&
2087  rOutlineNodes[iPos]->GetTextNode()->GetAttrOutlineLevel() > nLevel);
2088 
2089  // get the correct end node
2090  // the outline node may be in frames, headers, footers special section of doc model
2091  SwNode* pStartOfSectionNodeSttNd = pSttNd->StartOfSectionNode();
2092  while (pStartOfSectionNodeSttNd->StartOfSectionNode()
2093  != pStartOfSectionNodeSttNd->StartOfSectionNode()->StartOfSectionNode())
2094  {
2095  pStartOfSectionNodeSttNd = pStartOfSectionNodeSttNd->StartOfSectionNode();
2096  }
2097  pEndNd = pStartOfSectionNodeSttNd->EndOfSectionNode();
2098 
2099  if (iPos < rOutlineNodes.size())
2100  {
2101  SwNode* pStartOfSectionNode = rOutlineNodes[iPos]->StartOfSectionNode();
2102  while (pStartOfSectionNode->StartOfSectionNode()
2103  != pStartOfSectionNode->StartOfSectionNode()->StartOfSectionNode())
2104  {
2105  pStartOfSectionNode = pStartOfSectionNode->StartOfSectionNode();
2106  }
2107  if (pStartOfSectionNodeSttNd == pStartOfSectionNode)
2108  pEndNd = rOutlineNodes[iPos];
2109  }
2110  }
2111 
2112  // table, text box, header, footer
2113  if (pSttNd->GetTableBox() || pSttNd->GetIndex() < rNodes.GetEndOfExtras().GetIndex())
2114  {
2115  // limit to within section
2116  if (pSttNd->EndOfSectionIndex() < pEndNd->GetIndex())
2117  pEndNd = pSttNd->EndOfSectionNode();
2118  }
2119  // if pSttNd isn't in table but pEndNd is, skip over all outline nodes in table
2120  else if (pEndNd->GetTableBox())
2121  {
2122  pEndNd = &rNodes.GetEndOfContent();
2123  for (size_t nOutlinePos = nPos + 2; nOutlinePos < rOutlineNodes.size(); nOutlinePos++)
2124  {
2125  if (!(rOutlineNodes[nOutlinePos]->GetTableBox()))
2126  {
2127  pEndNd = rOutlineNodes[nOutlinePos];
2128  break;
2129  }
2130  }
2131  }
2132  // end node determined
2133 
2134  // Remove content frames from the next node after the starting outline node to
2135  // the determined ending node. Always do this to prevent the chance of duplicate
2136  // frames being made. They will be remade below if needed.
2137  SwNodeIndex aIdx(*pSttNd, +1);
2138  while (aIdx != *pEndNd)
2139  {
2140  SwNode* pNd = &aIdx.GetNode();
2141  if (pNd->IsContentNode())
2142  pNd->GetContentNode()->DelFrames(nullptr);
2143  else if (pNd->IsTableNode())
2144  pNd->GetTableNode()->DelFrames(nullptr);
2145  aIdx++;
2146  }
2147 
2148  if (bMakeVisible) // make outline nodes outline content visible
2149  {
2150  // reset the index marker and make frames
2151  aIdx.Assign(*pSttNd, +1);
2152  MakeFrames(GetDoc(), aIdx, *pEndNd);
2153 
2154  pSttNd->GetTextNode()->SetAttrOutlineContentVisible(true);
2155 
2156  // make outline content made visible that have outline visible attribute false not visible
2157  while (aIdx != *pEndNd)
2158  {
2159  SwNode* pNd = &aIdx.GetNode();
2160  if (pNd->IsTextNode() && pNd->GetTextNode()->IsOutline())
2161  {
2162  SwTextNode* pTextNd = pNd->GetTextNode();
2163  bool bOutlineContentVisibleAttr = true;
2164  pTextNd->GetAttrOutlineContentVisible(bOutlineContentVisibleAttr);
2165  if (!bOutlineContentVisibleAttr)
2166  {
2168  if (rOutlineNodes.Seek_Entry(pTextNd, &iPos))
2169  {
2170  if (pTextNd->getLayoutFrame(nullptr))
2171  MakeOutlineContentVisible(iPos, false);
2172  }
2173  }
2174  }
2175  aIdx++;
2176  }
2177  }
2178  else
2179  pSttNd->GetTextNode()->SetAttrOutlineContentVisible(false);
2180 }
2181 
2182 // make content visible or not visible only if needed
2184 {
2186 
2187  const SwOutlineNodes& rOutlineNds = GetNodes().GetOutLineNds();
2188  for (SwOutlineNodes::size_type nPos = 0; nPos < rOutlineNds.size(); ++nPos)
2189  {
2190  bool bIsOutlineContentVisible = IsOutlineContentVisible(nPos);
2191  bool bOutlineContentVisibleAttr = true;
2192  rOutlineNds[nPos]->GetTextNode()->GetAttrOutlineContentVisible(bOutlineContentVisibleAttr);
2193  if (!bIsOutlineContentVisible && bOutlineContentVisibleAttr)
2195  else if (bIsOutlineContentVisible && !bOutlineContentVisibleAttr)
2197  }
2198 }
2199 
2201 {
2202  // deselect any drawing or frame and leave editing mode
2203  SdrView* pSdrView = GetDrawView();
2204  if (pSdrView && pSdrView->IsTextEdit() )
2205  {
2206  bool bLockView = IsViewLocked();
2207  LockView(true);
2208  EndTextEdit();
2209  LockView(bLockView);
2210  }
2211 
2212  if (IsSelFrameMode() || IsObjSelected())
2213  {
2214  UnSelectFrame();
2217  EnterStdMode();
2218  DrawSelChanged();
2219  GetView().StopShellTimer();
2220  }
2221  else
2222  EnterStdMode();
2223 
2225 
2226  if (bMakeVisible)
2227  {
2228  // make all content visible
2229 
2230  // When shortcut is assigned to the show outline content visibility button and used to
2231  // toggle the feature and the mouse pointer is on an outline frame the button will not
2232  // be removed. An easy way to make sure the button does not remain shown is to use the
2233  // HideControls function.
2235 
2236  // temporarily set outline content visible attribute true for folded outline nodes
2237  std::vector<SwNode*> aFoldedOutlineNodeArray;
2238  for (SwNode* pNd: GetNodes().GetOutLineNds())
2239  {
2240  bool bOutlineContentVisibleAttr = true;
2241  pNd->GetTextNode()->GetAttrOutlineContentVisible(bOutlineContentVisibleAttr);
2242  if (!bOutlineContentVisibleAttr)
2243  {
2244  aFoldedOutlineNodeArray.push_back(pNd);
2245  pNd->GetTextNode()->SetAttrOutlineContentVisible(true);
2246  }
2247  }
2248 
2249  StartAction();
2251  EndAction();
2252 
2253  // restore outline content visible attribute for folded outline nodes
2254  for (SwNode* pNd: aFoldedOutlineNodeArray)
2255  pNd->GetTextNode()->SetAttrOutlineContentVisible(false);
2256  }
2257  else
2258  {
2259  StartAction();
2261  EndAction();
2262 
2263  // If needed, find visible outline node to place cursor.
2264  if (nPos != SwOutlineNodes::npos && !IsOutlineContentVisible(nPos))
2265  {
2266  while (nPos != SwOutlineNodes::npos && !GetNodes().GetOutLineNds()[nPos]->GetTextNode()->getLayoutFrame(nullptr))
2267  --nPos;
2268  if (nPos != SwOutlineNodes::npos)
2269  GotoOutline(nPos);
2270  }
2271  }
2272 }
2273 
2275 {
2276  bool bVisibleAttr = true;
2277  GetNodes().GetOutLineNds()[nPos]->GetTextNode()->GetAttrOutlineContentVisible(bVisibleAttr);
2278  return bVisibleAttr;
2279 }
2280 
2281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InsertLineBreak()
Definition: wrtsh1.cxx:940
const Fraction & GetScaleWidth() const
SfxViewFrame * GetViewFrame() const
SvxNumType GetNumberingType() const
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:683
void StopShellTimer()
Definition: view.cxx:1781
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
const SfxSlot * GetSlot(sal_uInt16 nId) const
const css::uno::Reference< css::embed::XEmbeddedObject > & GetObject() const
bool Right(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:127
void KillPams()
Definition: crsrsh.cxx:1022
sal_uLong GetIndex() const
Definition: node.hxx:291
virtual css::uno::Reference< css::io::XInputStream > GetIconIfIconified(OUString *pGraphicMediaType)=0
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
void SplitNode(bool bAutoFormat=false)
Definition: wrtsh1.cxx:1022
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2877
int GetAssignedOutlineStyleLevel() const
Definition: fmtcol.cxx:599
OUString const & GetCurPageStyle() const
Definition: wrtsh1.cxx:1597
void ChgDBData(const SwDBData &SwDBData)
Definition: edfld.cxx:294
bool bVisible
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
Rect of current FlyFrame.
static SvxAutoCorrCfg & Get()
Marks a position in the document model.
Definition: pam.hxx:35
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
void InsertByWord(const OUString &)
Definition: wrtsh1.cxx:191
const SwNodes & GetNodes() const
Definition: viewsh.cxx:2092
bool IsAutoCorrFlag(ACFlags nFlag) const
virtual void DrawSelChanged() override
Definition: wrtsh3.cxx:105
bool IsDrawMode() const
Definition: view.hxx:539
SdrView * GetDrawView()
Definition: vnew.cxx:373
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
size_t GetPageDescCnt() const
Definition: fedesc.cxx:38
void InsertObject( const svt::EmbeddedObjectRef &, SvGlobalName const *pName, sal_uInt16 nSlotId=0)
Definition: wrtsh1.cxx:387
bool IsDefault() const
Definition: format.hxx:113
bool SetObjArea(const tools::Rectangle &)
constexpr auto toTwips(N number, Length from)
SwTableBox * GetTableBox() const
If node is in a table return the respective table box.
Definition: node.cxx:754
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
Definition: ndtbl.cxx:2446
void BulletOn()
Definition: wrtsh1.cxx:1427
void setWidth(tools::Long nWidth)
SwView * GetActiveView()
Definition: swmodul1.cxx:116
static constexpr auto Items
bool IsOutline() const
Returns if this text node is an outline.
Definition: ndtxt.cxx:3985
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
OutlinerParaObject * IsAnswer()
Definition: PostItMgr.hxx:256
void UpdateAttrMgr()
Definition: frmmgr.cxx:136
bool IsBezierEditMode() const
Definition: viewdraw.cxx:626
void MakeOutlineContentVisible(const size_t nPos, bool bMakeVisible=true)
Definition: wrtsh1.cxx:2069
void InvalidateOutlineContentVisibility()
Definition: wrtsh1.cxx:2183
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
SwNodeIndex nNode
Definition: pam.hxx:37
bool IsTableMode() const
Definition: crsrsh.hxx:643
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
void SetFlyMacroLnk(const Link< const SwFlyFrameFormat *, void > &rLnk)
Definition: crsrsh.hxx:479
sal_uInt16 char char * pDesc
void Remove(const SvGlobalName &)
SVX_NUM_NUMBER_NONE
static SvxAbstractDialogFactory * Create()
long Long
void StopQuickHelp()
Definition: edtwin.cxx:5953
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1752
bool IsAutoRule() const
Definition: numrule.hxx:230
virtual void SetShowHeaderFooterSeparator(FrameControlType eControl, bool bShow) override
Definition: wrtsh1.cxx:1928
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1213
virtual OUString GetDescription() const
Definition: atrfrm.cxx:2858
Definition: doc.hxx:188
constexpr sal_uInt16 RES_FRMATR_END(133)
void SetNumStr(const OUString &rStr)
Definition: fmtftn.hxx:73
void HideControls(FrameControlType eType)
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:93
sal_Int16 nId
css::uno::Sequence< sal_Int8 > GetByteSequence() const
void AutoCorrect(SvxAutoCorrect &rACorr, bool bInsertMode, sal_Unicode cChar)
Call AutoCorrect.
Definition: edws.cxx:255
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
OUString GetSelDescr() const
Definition: wrtsh1.cxx:1798
SwNode & GetNode() const
Definition: ndindex.hxx:119
bool Left(sal_uInt16 nCnt, sal_uInt16 nMode, bool bAllowVisual=false)
Definition: crsrsh.hxx:349
SwTwips GetWidthOfLeadingTabs() const
Returns the width of leading tabs/blanks in this paragraph.
Definition: itratr.cxx:1448
static bool lcl_IsAllowed(const SwWrtShell *rSh)
Definition: wrtsh1.cxx:127
void EnterStdMode()
Definition: select.cxx:551
SwEditWin & GetEditWin()
Definition: view.hxx:416
SwFormatField * FindFormatForField(const SwField *) const
Definition: fldbas.cxx:174
void SetPageStyle(const OUString &rCollName)
Definition: wrtsh1.cxx:1585
void Pos(const Point &rNew)
Definition: swrect.hxx:168
void LaunchOLEObj(sal_Int32 nVerb=css::embed::EmbedVerbs::MS_OLEVERB_PRIMARY)
Definition: wrtsh1.cxx:632
ErrCode DoVerb(sal_Int32 nVerb)
bool GetAttrOutlineContentVisible(const size_t nPos)
Definition: wrtsh1.cxx:2274
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
void AutoUpdatePara(SwTextFormatColl *pColl, const SfxItemSet &rStyleSet, SwPaM *pPaM=nullptr)
Definition: wrtsh1.cxx:1617
void Invalidate(sal_uInt16 nId)
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:277
bool InsertField(const SwInsertField_Data &rData)
Definition: fldmgr.cxx:893
bool InsertOleObject(const svt::EmbeddedObjectRef &xObj, SwFlyFrameFormat **pFlyFrameFormat=nullptr)
Definition: wrtsh1.cxx:491
OUString GetCursorDescr() const
Returns textual description of the current selection.
Definition: crsrsh.cxx:3664
RndStdIds GetAnchor() const
Definition: frmmgr.hxx:167
void DelAttr(sal_uInt16 nId)
Definition: frmmgr.cxx:535
void EndAllAction()
Definition: edws.cxx:97
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4095
static sal_uInt16 IsChart(const SvGlobalName &rName)
void InsertPostIt(SwFieldMgr &rFieldMgr, const SfxRequest &rReq)
Inserts a new annotation/comment at the current cursor position / selection.
Definition: wrtsh1.cxx:1935
int GetAttrOutlineLevel() const
Returns outline level of this text node.
Definition: ndtxt.cxx:4015
void NoEdit(bool bHideCursor=true)
Definition: wrtsh1.cxx:167
virtual void SetReadonlyOption(bool bSet)
Definition: viewsh.cxx:2369
bool HasSelection() const
Does the current cursor create a selection?
Definition: crsrsh.cxx:2518
void SetAttrOutlineContentVisible(bool bVisible)
Definition: ndtxt.cxx:4038
const OUString & GetName() const
Definition: pagedesc.hxx:196
bool IsActive() const
Definition: fmthdft.hxx:89
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
constexpr tools::Long Width() const
static UITestLogger & getInstance()
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
bool IsHeaderFooterEdit() const
Acts both for headers / footers, depending on the bShow(Header|Footer)Separator flags.
Definition: viewsh.hxx:562
void logEvent(const EventDescription &rDescription)
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
sal_uInt16 sal_Unicode
const SfxPoolItem * NextItem()
tools::Long ResetSelect(const Point *, bool)
Definition: select.cxx:333
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:114
constexpr SwTwips DFLT_WIDTH
Definition: frmmgr.hxx:38
virtual void ApplyViewOptions(const SwViewOption &rOpt) override
Apply ViewOptions with Start-/EndAction.
Definition: editsh.cxx:1081
SwTableNode * GetTableNode()
Definition: node.hxx:600
const SwView & GetView() const
Definition: wrtsh.hxx:431
SwFrameControlsManager & GetFrameControlsManager()
Definition: edtwin.cxx:6609
RET_YES
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:171
SwIndex nContent
Definition: pam.hxx:38
sal_Unicode GetBulletChar(sal_uInt8 nLevel)
retrieve unicode of character used for the default bullet list for the given list level ...
Definition: number.cxx:1338
tools::Long CalcHeightBorder()
Definition: frmmgr.hxx:135
const OUString & GetName() const
Definition: format.hxx:115
void Edit()
Definition: wrtsh1.cxx:173
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
SVX_NUM_ARABIC
SELECTFUNC m_fnSetCursor
Definition: wrtsh.hxx:112
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
bool checkForSelectedFontWork(SdrView const *pSdrView)
void Width(tools::Long nNew)
Definition: swrect.hxx:186
const SfxItemSet & GetAttrSet() const
Definition: frmmgr.hxx:124
Numbering symbols.
Definition: poolfmt.hxx:117
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
SwFrameFormat * GetTableStyle(std::u16string_view rFormatName)
Definition: wrtsh1.cxx:1566
bool checkForSelectedCustomShapes(SdrView const *pSdrView, bool bOnlyExtruded)
static sal_uInt16 IsMath(const SvGlobalName &rName)
virtual void MoveObjectIfActive(svt::EmbeddedObjectRef &xObj, const Point &rOffset) override
The layout has been changed, so the active object has to be moved after that.
Definition: wrtsh1.cxx:660
size_type size() const
bool IsEmpty() const
Definition: swrect.hxx:291
void Insert(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:62
void MakeFrames(SwDoc *pDoc, const SwNodeIndex &rSttIdx, const SwNodeIndex &rEndIdx)
Definition: frmtool.cxx:1971
void NumOn()
Definition: wrtsh1.cxx:1376
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
bool IsFormProtected()
Definition: crbm.cxx:278
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
bool IsShowOutlineContentVisibilityButton() const
Definition: viewopt.cxx:99
SwWrtShell(SwWrtShell &, vcl::Window *pWin, SwView &rShell)
Definition: wrtsh1.cxx:1706
void SetReadonlyControls(bool bReadonly)
SVX_NUM_CHAR_SPECIAL
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
void SetHeightSizeType(SwFrameSize eType)
Definition: frmmgr.cxx:593
bool IsContentNode() const
Definition: node.hxx:629
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
Class for automated call of Start- and EndAction().
Definition: editsh.hxx:1013
bool IsSelection() const
Definition: crsrsh.hxx:879
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:2773
sal_uInt16 char * pName
std::unique_ptr< SwPaM > m_pAnnotationRange
Marks the PostIt field's annotation start/end if it differs from the cursor selection.
Definition: fldmgr.hxx:83
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:59
virtual SwPaM & GetCurrentShellCursor() override
Return the current shell cursor.
Definition: crsrsh.cxx:186
bool HasSelection() const
Definition: wrtsh.hxx:144
#define SW_MOD()
Definition: swmodule.hxx:256
static constexpr auto npos
Definition: ndarr.hxx:79
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
void Insert2(const OUString &, const bool bForceExpandHints=false)
Definition: editsh.cxx:80
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:132
bool IsFrameAction() const
Definition: edtwin.hxx:218
const SwFrameFormat * GetFooterFormat() const
Definition: fmthdft.hxx:85
const SwPosition * GetPoint() const
Definition: pam.hxx:207
bool SetCursorInHdFt(size_t nDescNo, bool bInHeader)
Definition: crstrvl.cxx:195
const vcl::Font & GetDefBulletFont()
retrieve font used for the default bullet list characters
Definition: number.cxx:1333
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
SelectionType
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void SetShowHeaderFooterSeparator(FrameControlType eControl, bool bShow)
Definition: viewsh.cxx:96
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2240
SwCharFormat * GetCharStyle(const OUString &rFormatName, GetStyle eCreate=GETSTYLE_NOCREATE)
Definition: wrtsh1.cxx:1549
SvxAutoCorrect * GetAutoCorrect()
SfxBindings & GetBindings()
void Assign(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
SwContentNode * GetContentNode()
Definition: node.hxx:616
const OUString & GetValue() const
const SwPageDesc & GetPageDesc(size_t i) const
Definition: fedesc.cxx:126
void SetTextFormatColl(const css::uno::Any &rAny, SwPaM &rPaM)
const T * GetArg(sal_uInt16 nSlotId) const
void SetSfxViewShell(SfxViewShell *pNew)
Definition: viewsh.hxx:442
void DelFrames(SwRootFrame const *pLayout)
Method deletes all views of document for the node.
Definition: node.cxx:1409
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
SwField * GetCurField()
Definition: fldmgr.cxx:428
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:27
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
void SetGraphicStream(const css::uno::Reference< css::io::XInputStream > &xInGrStream, const OUString &rMediaType)
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2807
void SetAnchor(RndStdIds eId)
Definition: frmmgr.cxx:227
void NumOrBulletOff()
Definition: wrtsh1.cxx:1381
Marks a node in the document model.
Definition: ndindex.hxx:31
void ToggleHeaderFooterEdit()
Definition: fews.cxx:1320
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:231
void MakeAllFoldedOutlineContentVisible(bool bMakeVisible=true)
Definition: wrtsh1.cxx:2200
virtual void SetReadonlyOption(bool bSet) override
Definition: wrtsh1.cxx:1837
#define CNT_OLE
Definition: editsh.hxx:131
SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel=UCHAR_MAX, SwPaM *pPaM=nullptr)
search "outline position" before previous outline node at given level
Definition: crstrvl.cxx:1138
void SSize(const Size &rNew)
Definition: swrect.hxx:177
void PopMode()
Definition: select.cxx:284
void LeaveDrawCreate()
Definition: view.hxx:538
void Insert(const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic, const SfxItemSet *pFlyAttrSet)
Definition: fefly1.cxx:824
Frame cannot be moved in Var-direction.
tools::Long SwTwips
Definition: swtypes.hxx:52
const SwNumRuleItem & GetNumRule(bool=true) const
Definition: paratr.hxx:232
const char * GetUnoName() const
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNodeIndex const &rNode)
Definition: txtfrm.cxx:328
SwFieldType * GetTyp() const
Definition: fldbas.hxx:392
SwFrameFormat * GetSelectedFrameFormat() const
If frame then frame style, else 0.
Definition: fefly1.cxx:1203
void ChangeIndent(const sal_Int32 nDiff)
change indent of all list levels by given difference
Definition: number.cxx:945
SW_DLLPUBLIC bool HasActiveSidebarWin() const
Definition: PostItMgr.cxx:2350
virtual void CalcAndSetScale(svt::EmbeddedObjectRef &xObj, const SwRect *pFlyPrtRect=nullptr, const SwRect *pFlyFrameRect=nullptr, const bool bNoTextFramePrtAreaChanged=false) override
Client for OleObject has to be up-to-date regarding scaling.
Definition: wrtsh1.cxx:683
void StartAction()
Definition: crsrsh.cxx:227
constexpr TypedWhichId< SvxRsidItem > RES_CHRATR_RSID(39)
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
void ChangeHeaderOrFooter(std::u16string_view rStyleName, bool bHeader, bool bOn, bool bShowWarning)
Definition: wrtsh1.cxx:1846
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
Definition: viscrs.cxx:588
SwFlyFrameFormat * InsertObject(const svt::EmbeddedObjectRef &, SfxItemSet *pFlyAttrSet)
Definition: fefly1.cxx:917
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:79
const sal_uInt16 CRSR_SKIP_CELLS
Definition: swcrsr.hxx:66
virtual css::uno::Reference< css::embed::XEmbeddedObject > GetObject()=0
void InsertFootnote(const OUString &, bool bEndNote=false, bool bEdit=true)
Definition: wrtsh1.cxx:989
FrameControlType
Definition: swtypes.hxx:234
Class for automated call of Start- and EndCursorMove().
Definition: editsh.hxx:1021
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:678
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void NumOrBulletOn(bool bNum)
Turns on numbering or bullets.
Definition: wrtsh1.cxx:1060
void addCurrentPosition()
Definition: wrtsh1.cxx:1578
void Set(sal_uInt16 i, const SwNumFormat *)
Definition: number.cxx:603
virtual ~SwWrtShell() override
Definition: wrtsh1.cxx:1742
void SetCharFormat(SwCharFormat *)
Definition: number.cxx:273
#define BITFLD_INI_LIST
Definition: wrtsh1.cxx:144
::sw::mark::IFieldmark * GetFieldmarkAfter()
Definition: crbm.cxx:290
virtual bool IsTextEdit() const final override
tools::Rectangle SVRect() const
Definition: swrect.hxx:279
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
bool IsOutlineContentVisible(const size_t nPos)
Definition: wrtsh1.cxx:2035
SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
Definition: number.cxx:1499
weld::Window * GetFrameWeld() const
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
bool IsDefBulletFontUserDefined()
determine if default bullet font is user defined
Definition: number.cxx:1328
static MapUnit UnoEmbed2VCLMapUnit(sal_Int32 nUnoEmbedMapUnit)
constexpr tools::Long Height() const
constexpr SwTwips DFLT_HEIGHT
Definition: frmmgr.hxx:39
unsigned char sal_uInt8
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
void LockView(bool b)
Definition: viewsh.hxx:462
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
static void ClearSelection(SwWrtShell &rSh, const SwFrameShell *pCreator=nullptr)
Definition: swdtflvr.cxx:4185
tools::Long CalcWidthBorder()
Definition: frmmgr.hxx:134
OUString aName
sal_Int32 GetIndex() const
Definition: index.hxx:91
bool IsCountedInList() const
Definition: ndtxt.cxx:4233
const tools::Rectangle & GetObjArea() const
SwNodes & GetNodes()
Definition: doc.hxx:409
tools::Long AdjustWidth(tools::Long n)
bool IsModePushed() const
Definition: wrtsh.hxx:135
void ChgPageDesc(size_t i, const SwPageDesc &)
Definition: fedesc.cxx:111
constexpr sal_uInt16 RES_PARATR_END(82)
SwPostItMgr * GetPostItMgr()
Definition: view.hxx:639
void GotoOutline(SwOutlineNodes::size_type nIdx)
Definition: move.cxx:617
bool CanInsert()
Definition: wrtsh1.cxx:1766
void NotifyDBChanged()
Definition: view.cxx:1876
Size GetSize(MapMode const *pTargetMapMode) const
void EndTextEdit()
Deletes object if required.
Definition: feshview.cxx:1308
size_t IsObjSelected() const
Definition: feshview.cxx:1240
void UnSelectFrame()
Definition: select.cxx:323
void SetSize(const Size &rLSize)
Definition: frmmgr.cxx:614
void SetObjAreaAndScale(const tools::Rectangle &, const Fraction &, const Fraction &)
void AutoUpdateFrame(SwFrameFormat *pFormat, const SfxItemSet &rStyleSet)
Definition: wrtsh1.cxx:1656
tools::Long AdjustHeight(tools::Long n)
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
#define FN_VIEW_META_CHARS
Definition: cmdid.h:159
void InsertColumnBreak()
Definition: wrtsh1.cxx:963
constexpr sal_uInt16 RES_CHRATR_END(46)
SAL_DLLPRIVATE tools::Long SetCursorKillSel(const Point *, bool bProp)
Definition: select.cxx:316
const SwPostItMgr * GetPostItMgr() const
Definition: viewsh.hxx:556
bool IsTreatSubOutlineLevelsAsContent() const
Definition: viewopt.cxx:105
void LeaveSelFrameMode()
Definition: select.cxx:720
virtual bool IsCreateNew()=0
SwFormatColl * GetCurTextFormatColl(SwPaM &rPam, const bool bConditional)
Definition: unoobj.cxx:616
void setHeight(tools::Long nHeight)
void AutoCorrect(SvxAutoCorrect &rACorr, sal_Unicode cChar)
Definition: wrtsh1.cxx:1666
void Overwrite(const OUString &)
Definition: editsh.cxx:169
static SvxAutoCorrect * lcl_IsAutoCorr()
Definition: wrtsh1.cxx:157
bool IsEndWrd()
Definition: wrtsh1.cxx:181
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:65
MapUnit
RndStdIds
void SetNumOffset(const ::std::optional< sal_uInt16 > &oNum)
Definition: fmtpdsc.hxx:65
bool IsTableNode() const
Definition: node.hxx:641
SwTwips GetAdditionalIndentForStartingNewList() const
Definition: ndtxt.cxx:3232
bool IsInList() const
Definition: ndtxt.cxx:4337
void InsertPageBreak(const OUString *pPageDesc=nullptr, const ::std::optional< sal_uInt16 > &rPgNum=std::nullopt)
Definition: wrtsh1.cxx:902
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
bool IsAddMode() const
Definition: wrtsh.hxx:159
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:248
Left
void ChgDBData(const SwDBData &SwDBData)
Definition: wrtsh1.cxx:1791
constexpr tools::Long constTwips_5mm
Definition: pggrid.cxx:38
bool IsEndPara() const
Definition: crsrsh.cxx:1114
SAL_DLLPRIVATE bool PopCursor(bool bUpdate, bool bSelect=false)
Definition: move.cxx:485
void SplitNode(bool bAutoFormat=false, bool bCheckTableStart=true)
Definition: editsh.cxx:183
bool Pop(PopMode)
delete cursor
Definition: crsrsh.cxx:2262
bool Seek_Entry(SwNode *rP, size_type *pnPos) const
Definition: ndnum.cxx:32
const Size & GetSize() const
Definition: frmmgr.hxx:138
void GetAttrOutlineContentVisible(bool &bOutlineContentVisibleAttr)
GetAttrOutlineContentVisible.
Definition: ndtxt.cxx:4030
void SetNumberingType(SvxNumType nSet)
virtual void ConnectObj(svt::EmbeddedObjectRef &xIPObj, const SwRect &rPrt, const SwRect &rFrame) override
Connect objects with ActivateWhenVisible at Paint.
Definition: wrtsh1.cxx:891
std::map< OUString, OUString > aParameters
bool IsActive() const
Definition: fmthdft.hxx:58
sal_Int64 GetViewAspect() const
bool IsInvalidItem(const SfxPoolItem *pItem)
std::vector< SwNode * >::size_type size_type
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:161
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1432
virtual void ApplyViewOptions(const SwViewOption &rOpt) override
Apply ViewOptions with Start-/EndAction.
Definition: wrtsh1.cxx:1830
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
const Fraction & GetScaleHeight() const
bool GotoFieldmark(::sw::mark::IFieldmark const *const pMark)
Definition: wrtsh3.cxx:86
void RegisterAnswerText(const OUString &aAnswerText)
Definition: PostItMgr.hxx:257
tools::Long GetIndentAt() const
CharClass & GetAppCharClass()
Definition: init.cxx:703
bool IsTextNode() const
Definition: node.hxx:637
void Height(tools::Long nNew)
Definition: swrect.hxx:190
const OUString & GetAnswerText() const
Definition: PostItMgr.hxx:258
SwFieldIds Which() const
Definition: fldbas.hxx:272
sal_Int32 nState
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
Rect of PrtArea of FlyFrame.
void QuickUpdateStyle()
Definition: wrtsh1.cxx:1604
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool IsViewLocked() const
Definition: viewsh.hxx:461
bool IsOutlineRule() const
Definition: numrule.hxx:242
Definition: view.hxx:144
SELECTFUNC m_fnKillSel
Definition: wrtsh.hxx:114
const SwFrameFormat * GetHeaderFormat() const
Definition: fmthdft.hxx:54
sal_uInt16 nPos
const SfxPoolItem * GetCurItem() const
bool IsSelFrameMode() const
Definition: wrtsh.hxx:173
SwTextFormatColl * GetParaStyle(const OUString &rCollName, GetStyle eCreate=GETSTYLE_NOCREATE)
Definition: wrtsh1.cxx:1532
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:850
void UpdateFlyFrame()
Definition: frmmgr.cxx:160
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Definition: ndindex.hxx:272
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:244
Base class of the Writer document model elements.
Definition: node.hxx:80