LibreOffice Module sw (master)  1
docst.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 <memory>
21 
22 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/container/XNameAccess.hpp>
25 #include <com/sun/star/frame/XModel.hpp>
26 #include <comphelper/flagguard.hxx>
27 #include <o3tl/any.hxx>
28 #include <sal/log.hxx>
29 #include <osl/diagnose.h>
30 #include <hintids.hxx>
31 #include <sfx2/styledlg.hxx>
32 #include <svl/whiter.hxx>
33 #include <sfx2/tplpitem.hxx>
34 #include <sfx2/request.hxx>
35 #include <sfx2/dispatch.hxx>
36 #include <sfx2/newstyle.hxx>
37 #include <sfx2/printer.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <svl/stritem.hxx>
40 #include <svl/languageoptions.hxx>
41 #include <sfx2/htmlmode.hxx>
42 #include <swmodule.hxx>
43 #include <fchrfmt.hxx>
44 #include <svtools/htmlcfg.hxx>
45 #include <svx/xdef.hxx>
46 #include <SwStyleNameMapper.hxx>
47 #include <SwRewriter.hxx>
48 #include <numrule.hxx>
49 #include <swundo.hxx>
50 #include <svx/drawitem.hxx>
51 #include <view.hxx>
52 #include <wrtsh.hxx>
53 #include <docsh.hxx>
54 #include <uitool.hxx>
55 #include <cmdid.h>
56 #include <viewopt.hxx>
57 #include <doc.hxx>
58 #include <drawdoc.hxx>
60 #include <IDocumentUndoRedo.hxx>
64 #include <IDocumentState.hxx>
65 #include <frmfmt.hxx>
66 #include <charfmt.hxx>
67 #include <poolfmt.hxx>
68 #include <pagedesc.hxx>
69 #include <docstyle.hxx>
70 #include <uiitems.hxx>
71 #include <fmtcol.hxx>
72 #include <edtwin.hxx>
73 #include <unochart.hxx>
74 #include <swabstdlg.hxx>
75 #include <paratr.hxx>
76 #include <tblafmt.hxx>
77 #include <sfx2/watermarkitem.hxx>
78 #include <svl/grabbagitem.hxx>
79 #include <SwUndoFmt.hxx>
80 #include <strings.hrc>
81 #include <AccessibilityCheck.hxx>
82 
83 using namespace ::com::sun::star;
84 
86 {
87  SfxWhichIter aIter(rSet);
88  sal_uInt16 nWhich = aIter.FirstWhich();
89  SfxStyleFamily nActualFamily = SfxStyleFamily(USHRT_MAX);
90 
91  SwWrtShell* pShell = pSh ? pSh : GetWrtShell();
92  if(!pShell)
93  {
94  while (nWhich)
95  {
96  rSet.DisableItem(nWhich);
97  nWhich = aIter.NextWhich();
98  }
99  return;
100  }
101  else
102  {
103  SfxViewFrame* pFrame = pShell->GetView().GetViewFrame();
104  std::unique_ptr<SfxPoolItem> pItem;
105  pFrame->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
106  SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
107  if (pFamilyItem)
108  {
109  nActualFamily = static_cast<SfxStyleFamily>(pFamilyItem->GetValue());
110  }
111  }
112 
113  while (nWhich)
114  {
115  // determine current template to every family
116  OUString aName;
117  SwTableAutoFormat aTableAutoFormat("dummy"); // needed to check if can take a table auto format at current cursor position
118  switch (nWhich)
119  {
120  case SID_STYLE_APPLY:
121  {// here the template and its family are passed to the StyleBox
122  // so that this family is being showed
123  if(pShell->IsFrameSelected())
124  {
125  SwFrameFormat* pFormat = pShell->GetSelectedFrameFormat();
126  if( pFormat )
127  aName = pFormat->GetName();
128  }
129  else
130  {
131  SwTextFormatColl* pColl = pShell->GetCurTextFormatColl();
132  if(pColl)
133  aName = pColl->GetName();
134  }
135  rSet.Put(SfxTemplateItem(nWhich, aName));
136  }
137  break;
138  case SID_STYLE_FAMILY1:
139  if( !pShell->IsFrameSelected() )
140  {
141  SwCharFormat* pFormat = pShell->GetCurCharFormat();
142  if(pFormat)
143  aName = pFormat->GetName();
144  else
145  aName = SwResId(STR_POOLCHR_STANDARD);
146  rSet.Put(SfxTemplateItem(nWhich, aName));
147  }
148  break;
149 
150  case SID_STYLE_FAMILY2:
151  if(!pShell->IsFrameSelected())
152  {
153  SwTextFormatColl* pColl = pShell->GetCurTextFormatColl();
154  if(pColl)
155  aName = pColl->GetName();
156 
157  SfxTemplateItem aItem(nWhich, aName);
158 
159  SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto;
160  if (m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE))
161  nMask = SfxStyleSearchBits::SwHtml;
162  else
163  {
164  const FrameTypeFlags nSelection = pShell->GetFrameType(nullptr,true);
165  if(pShell->GetCurTOX())
166  nMask = SfxStyleSearchBits::SwIndex ;
167  else if(nSelection & FrameTypeFlags::HEADER ||
168  nSelection & FrameTypeFlags::FOOTER ||
169  nSelection & FrameTypeFlags::TABLE ||
170  nSelection & FrameTypeFlags::FLY_ANY ||
171  nSelection & FrameTypeFlags::FOOTNOTE ||
172  nSelection & FrameTypeFlags::FTNPAGE)
173  nMask = SfxStyleSearchBits::SwExtra;
174  else
175  nMask = SfxStyleSearchBits::SwText;
176  }
177 
178  aItem.SetValue(nMask);
179  rSet.Put(aItem);
180  }
181 
182  break;
183 
184  case SID_STYLE_FAMILY3:
185 
186  if (m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE))
187  rSet.DisableItem( nWhich );
188  else
189  {
190  SwFrameFormat* pFormat = pShell->GetSelectedFrameFormat();
191  if(pFormat && pShell->IsFrameSelected())
192  {
193  aName = pFormat->GetName();
194  rSet.Put(SfxTemplateItem(nWhich, aName));
195  }
196  }
197  break;
198 
199  case SID_STYLE_FAMILY4:
200  {
201  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
202  if (m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !rHtmlOpt.IsPrintLayoutExtension())
203  rSet.DisableItem( nWhich );
204  else
205  {
206  size_t n = pShell->GetCurPageDesc( false );
207  if( n < pShell->GetPageDescCnt() )
208  aName = pShell->GetPageDesc( n ).GetName();
209 
210  rSet.Put(SfxTemplateItem(nWhich, aName));
211  }
212  }
213  break;
214  case SID_STYLE_FAMILY5:
215  {
216  const SwNumRule* pRule = pShell->GetNumRuleAtCurrCursorPos();
217  if( pRule )
218  aName = pRule->GetName();
219 
220  rSet.Put(SfxTemplateItem(nWhich, aName));
221  }
222  break;
223  case SID_STYLE_FAMILY6:
224  {
225  const SwTableNode *pTableNd = pShell->IsCursorInTable();
226  if( pTableNd )
227  aName = pTableNd->GetTable().GetTableStyleName();
228 
229  rSet.Put(SfxTemplateItem(nWhich, aName));
230  }
231  break;
232 
233  case SID_STYLE_WATERCAN:
234  {
235  SwEditWin& rEdtWin = pShell->GetView().GetEditWin();
236  SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
237  rSet.Put(SfxBoolItem(nWhich, pApply && pApply->eType != SfxStyleFamily(0)));
238  }
239  break;
240  case SID_STYLE_UPDATE_BY_EXAMPLE:
241  if( pShell->IsFrameSelected()
242  ? SfxStyleFamily::Frame != nActualFamily
243  : ( SfxStyleFamily::Frame == nActualFamily ||
244  SfxStyleFamily::Page == nActualFamily ||
245  (SfxStyleFamily::Pseudo == nActualFamily && !pShell->GetNumRuleAtCurrCursorPos()) ||
246  (SfxStyleFamily::Table == nActualFamily && !pShell->GetTableAutoFormat(aTableAutoFormat))) )
247  {
248  rSet.DisableItem( nWhich );
249  }
250  break;
251 
252  case SID_STYLE_NEW_BY_EXAMPLE:
253  if( (pShell->IsFrameSelected()
254  ? SfxStyleFamily::Frame != nActualFamily
255  : SfxStyleFamily::Frame == nActualFamily) ||
256  (SfxStyleFamily::Pseudo == nActualFamily && !pShell->GetNumRuleAtCurrCursorPos()) ||
257  (SfxStyleFamily::Table == nActualFamily && !pShell->GetTableAutoFormat(aTableAutoFormat)) )
258  {
259  rSet.DisableItem( nWhich );
260  }
261  break;
262 
263  case SID_CLASSIFICATION_APPLY:
264  // Just trigger ClassificationCategoriesController::statusChanged().
265  rSet.InvalidateItem(nWhich);
266  break;
267  case SID_CLASSIFICATION_DIALOG:
268  rSet.InvalidateItem(nWhich);
269  break;
270  case SID_STYLE_EDIT:
271  break;
272  case SID_WATERMARK:
273  if (pSh)
274  {
275  SfxWatermarkItem aItem = pSh->GetWatermark();
276  rSet.Put(aItem);
277  }
278  break;
279  default:
280  OSL_FAIL("Invalid SlotId");
281  }
282  nWhich = aIter.NextWhich();
283  }
284 }
285 
286 // evaluate StyleSheet-Requests
288 {
289  sal_uInt16 nSlot = rReq.GetSlot();
290 
291  const SfxItemSet* pArgs = rReq.GetArgs();
292  const SfxPoolItem* pItem;
293  switch (nSlot)
294  {
295  case SID_STYLE_NEW:
296  if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY,
297  false, &pItem ))
298  {
299  const SfxStyleFamily nFamily = static_cast<SfxStyleFamily>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
300 
301  OUString sName;
302  SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto;
303  if( SfxItemState::SET == pArgs->GetItemState( SID_STYLE_NEW,
304  false, &pItem ))
305  sName = static_cast<const SfxStringItem*>(pItem)->GetValue();
306  if( SfxItemState::SET == pArgs->GetItemState( SID_STYLE_MASK,
307  false, &pItem ))
308  nMask = static_cast<SfxStyleSearchBits>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
309  OUString sParent;
310  if( SfxItemState::SET == pArgs->GetItemState( SID_STYLE_REFERENCE,
311  false, &pItem ))
312  sParent = static_cast<const SfxStringItem*>(pItem)->GetValue();
313 
314  if (sName.isEmpty() && m_xBasePool)
316 
317  Edit(sName, sParent, nFamily, nMask, true, OString(), nullptr, &rReq, nSlot);
318  }
319  break;
320 
321  case SID_STYLE_APPLY:
322  if( !pArgs )
323  {
324  GetView()->GetViewFrame()->GetDispatcher()->Execute(SID_STYLE_DESIGNER);
325  break;
326  }
327  else
328  {
329  // convert internal StyleName to DisplayName (slot implementation uses the latter)
330  const SfxStringItem* pNameItem = rReq.GetArg<SfxStringItem>(SID_APPLY_STYLE);
331  const SfxStringItem* pFamilyItem = rReq.GetArg<SfxStringItem>(SID_STYLE_FAMILYNAME);
332  if ( pFamilyItem && pNameItem )
333  {
334  uno::Reference< style::XStyleFamiliesSupplier > xModel(GetModel(), uno::UNO_QUERY);
335  try
336  {
337  uno::Reference< container::XNameAccess > xStyles;
338  uno::Reference< container::XNameAccess > xCont = xModel->getStyleFamilies();
339  xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
340  uno::Reference< beans::XPropertySet > xInfo;
341  xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
342  OUString aUIName;
343  xInfo->getPropertyValue("DisplayName") >>= aUIName;
344  if ( !aUIName.isEmpty() )
345  rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
346  }
347  catch (const uno::Exception&)
348  {
349  }
350  }
351  }
352 
353  [[fallthrough]];
354 
355  case SID_STYLE_EDIT:
356  case SID_STYLE_DELETE:
357  case SID_STYLE_HIDE:
358  case SID_STYLE_SHOW:
359  case SID_STYLE_WATERCAN:
360  case SID_STYLE_FAMILY:
361  case SID_STYLE_UPDATE_BY_EXAMPLE:
362  case SID_STYLE_NEW_BY_EXAMPLE:
363  {
364  OUString aParam;
365  SfxStyleFamily nFamily = SfxStyleFamily::Para;
366  SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto;
367  SwWrtShell* pActShell = nullptr;
368 
369  if( !pArgs )
370  {
371  switch (nSlot)
372  {
373  case SID_STYLE_NEW_BY_EXAMPLE:
374  {
376  SfxNewStyleDlg aDlg(GetView()->GetFrameWeld(), rPool, nFamily);
377  if (aDlg.run() == RET_OK)
378  {
379  aParam = aDlg.GetName();
380  rReq.AppendItem(SfxStringItem(nSlot, aParam));
381  }
382  }
383  break;
384 
385  case SID_STYLE_UPDATE_BY_EXAMPLE:
386  case SID_STYLE_EDIT:
387  {
389  if(pColl)
390  {
391  aParam = pColl->GetName();
392  rReq.AppendItem(SfxStringItem(nSlot, aParam));
393  }
394  }
395  break;
396  }
397  }
398  else
399  {
400  SAL_WARN_IF( !pArgs->Count(), "sw.ui", "SfxBug ItemSet is empty" );
401 
402  SwWrtShell* pShell = GetWrtShell();
403  if( SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
404  aParam = static_cast<const SfxStringItem*>(pItem)->GetValue();
405 
406  if( SfxItemState::SET == pArgs->GetItemState(SID_STYLE_FAMILY,
407  false, &pItem ))
408  nFamily = static_cast<SfxStyleFamily>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
409 
410  if( SfxItemState::SET == pArgs->GetItemState(SID_STYLE_FAMILYNAME, false, &pItem ))
411  {
412  OUString aFamily = static_cast<const SfxStringItem*>(pItem)->GetValue();
413  if(aFamily == "CharacterStyles")
414  nFamily = SfxStyleFamily::Char;
415  else
416  if(aFamily == "ParagraphStyles")
417  nFamily = SfxStyleFamily::Para;
418  else
419  if(aFamily == "PageStyles")
420  nFamily = SfxStyleFamily::Page;
421  else
422  if(aFamily == "FrameStyles")
423  nFamily = SfxStyleFamily::Frame;
424  else
425  if(aFamily == "NumberingStyles")
426  nFamily = SfxStyleFamily::Pseudo;
427  else
428  if(aFamily == "TableStyles")
429  nFamily = SfxStyleFamily::Table;
430  }
431 
432  if( SfxItemState::SET == pArgs->GetItemState(SID_STYLE_MASK,
433  false, &pItem ))
434  nMask = static_cast<SfxStyleSearchBits>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
435  if( SfxItemState::SET == pArgs->GetItemState(FN_PARAM_WRTSHELL,
436  false, &pItem ))
437  pActShell = pShell = static_cast<SwWrtShell*>(static_cast<const SwPtrItem*>(pItem)->GetValue());
438 
439  if( nSlot == SID_STYLE_UPDATE_BY_EXAMPLE && aParam.isEmpty() )
440  {
441  switch( nFamily )
442  {
443  case SfxStyleFamily::Para:
444  {
445  SwTextFormatColl* pColl = pShell->GetCurTextFormatColl();
446  if(pColl)
447  aParam = pColl->GetName();
448  }
449  break;
450  case SfxStyleFamily::Frame:
451  {
453  if( pFrame )
454  aParam = pFrame->GetName();
455  }
456  break;
457  case SfxStyleFamily::Char:
458  {
460  if( pChar )
461  aParam = pChar->GetName();
462  }
463  break;
464  case SfxStyleFamily::Pseudo:
465  if(SfxItemState::SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, false, &pItem))
466  {
467  aParam = static_cast<const SfxStringItem*>(pItem)->GetValue();
468  }
469  break;
470  case SfxStyleFamily::Table:
471  if(SfxItemState::SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, false, &pItem))
472  {
473  aParam = static_cast<const SfxStringItem*>(pItem)->GetValue();
474  }
475  break;
476  default: break;
477  }
478  rReq.AppendItem(SfxStringItem(nSlot, aParam));
479  }
480  }
481  if (!aParam.isEmpty() || nSlot == SID_STYLE_WATERCAN )
482  {
483  sal_uInt16 nRet = 0xffff;
484  bool bReturns = false;
485 
486  switch(nSlot)
487  {
488  case SID_STYLE_EDIT:
489  Edit(aParam, OUString(), nFamily, nMask, false, OString(), pActShell);
490  break;
491  case SID_STYLE_DELETE:
492  Delete(aParam, nFamily);
493  break;
494  case SID_STYLE_HIDE:
495  case SID_STYLE_SHOW:
496  Hide(aParam, nFamily, nSlot == SID_STYLE_HIDE);
497  break;
498  case SID_STYLE_APPLY:
499  // Shell-switch in ApplyStyles
500  nRet = static_cast<sal_uInt16>(ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() ));
501  bReturns = true;
502  break;
503  case SID_STYLE_WATERCAN:
504  nRet = static_cast<sal_uInt16>(DoWaterCan(aParam, nFamily));
505  bReturns = true;
506  break;
507  case SID_STYLE_UPDATE_BY_EXAMPLE:
508  UpdateStyle(aParam, nFamily, pActShell);
509  break;
510  case SID_STYLE_NEW_BY_EXAMPLE:
511  MakeByExample(aParam, nFamily, nMask, pActShell);
512  break;
513 
514  default:
515  OSL_FAIL("Invalid SlotId");
516  }
517 
518  if (bReturns)
519  {
520  if(rReq.IsAPI()) // Basic only gets TRUE or FALSE
521  rReq.SetReturnValue(SfxUInt16Item(nSlot, sal_uInt16(nRet !=0)));
522  else
523  rReq.SetReturnValue(SfxUInt16Item(nSlot, nRet));
524  }
525 
526  rReq.Done();
527  }
528 
529  break;
530  }
531  }
532 }
533 
534 namespace {
535 
536 class ApplyStyle
537 {
538 public:
539  ApplyStyle(SwDocShell &rDocSh, bool bNew,
542  rtl::Reference< SfxStyleSheetBasePool > const & xBasePool,
543  bool bModified)
544  : m_pDlg(pDlg)
545  , m_rDocSh(rDocSh)
546  , m_bNew(bNew)
547  , m_xTmp(xTmp)
548  , m_nFamily(nFamily)
549  , m_xBasePool(xBasePool)
550  , m_bModified(bModified)
551  {
552  }
553  DECL_LINK( ApplyHdl, LinkParamNone*, void );
554  void apply()
555  {
556  ApplyHdl(nullptr);
557  }
559  // true if the document was initially modified before ApplyStyle was created
560  // or if ApplyStyle:::apply was called
561  bool DocIsModified() const
562  {
563  return m_bModified;
564  }
565 private:
566  SwDocShell &m_rDocSh;
567  bool m_bNew;
569  SfxStyleFamily m_nFamily;
571  bool m_bModified;
572 };
573 
574 }
575 
576 IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void)
577 {
578  SwWrtShell* pWrtShell = m_rDocSh.GetWrtShell();
579  SwDoc* pDoc = m_rDocSh.GetDoc();
580  SwView* pView = m_rDocSh.GetView();
581 
582  pWrtShell->StartAllAction();
583 
584  if( SfxStyleFamily::Para == m_nFamily )
585  {
586  SfxItemSet aSet( *m_pDlg->GetOutputItemSet() );
587  ::ConvertAttrGenToChar(aSet, m_xTmp->GetItemSet(), /*bIsPara=*/true);
588  ::SfxToSwPageDescAttr( *pWrtShell, aSet );
589  // reset indent attributes at paragraph style, if a list style
590  // will be applied and no indent attributes will be applied.
591  m_xTmp->SetItemSet( aSet, true );
592  }
593  else
594  {
595  if(SfxStyleFamily::Page == m_nFamily)
596  {
597  static const sal_uInt16 aInval[] = {
598  SID_IMAGE_ORIENTATION,
599  SID_ATTR_CHAR_FONT,
601  pView->GetViewFrame()->GetBindings().Invalidate(aInval);
602  }
603  SfxItemSet aTmpSet( *m_pDlg->GetOutputItemSet() );
604  if( SfxStyleFamily::Char == m_nFamily )
605  {
606  ::ConvertAttrGenToChar(aTmpSet, m_xTmp->GetItemSet());
607  }
608 
609  m_xTmp->SetItemSet( aTmpSet );
610 
611  if( SfxStyleFamily::Page == m_nFamily && SvtLanguageOptions().IsCTLFontEnabled() )
612  {
613  const SfxPoolItem *pItem = nullptr;
614  if( aTmpSet.GetItemState( m_rDocSh.GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, false ) , true, &pItem ) == SfxItemState::SET )
616  }
617 
618  if (m_nFamily == SfxStyleFamily::Page)
619  {
620  const SfxPoolItem* pItem = nullptr;
621  if (aTmpSet.HasItem(SID_ATTR_CHAR_GRABBAG, &pItem))
622  {
623  const auto& rGrabBagItem = static_cast<const SfxGrabBagItem&>(*pItem);
624  bool bGutterAtTop{};
625  auto it = rGrabBagItem.GetGrabBag().find("GutterAtTop");
626  if (it != rGrabBagItem.GetGrabBag().end())
627  {
628  it->second >>= bGutterAtTop;
629  }
630  bool bOldGutterAtTop
632  if (bOldGutterAtTop != bGutterAtTop)
633  {
635  bGutterAtTop);
636  pWrtShell->InvalidateLayout(/*bSizeChanged=*/true);
637  }
638  }
639  }
640  }
641 
642  if(m_bNew)
643  {
644  if(SfxStyleFamily::Frame == m_nFamily || SfxStyleFamily::Para == m_nFamily)
645  {
646  // clear FillStyle so that it works as a derived attribute
647  SfxItemSet aTmpSet(*m_pDlg->GetOutputItemSet());
648 
649  aTmpSet.ClearItem(XATTR_FILLSTYLE);
650  m_xTmp->SetItemSet(aTmpSet);
651  }
652  }
653 
654  if(SfxStyleFamily::Page == m_nFamily)
655  pView->InvalidateRulerPos();
656 
657  if( m_bNew )
658  m_xBasePool->Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetCreated, *m_xTmp));
659  else
660  m_xBasePool->Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetModified, *m_xTmp));
661 
662  pDoc->getIDocumentState().SetModified();
663  if( !m_bModified )
664  {
666  m_bModified = true;
667  }
668 
669  pWrtShell->EndAllAction();
670 }
671 
672 namespace
673 {
676 void syncEndnoteOrientation(const uno::Reference< style::XStyleFamiliesSupplier >& xStyleFamSupp)
677 {
678  if (!xStyleFamSupp.is())
679  {
680  SAL_WARN("sw.ui", "Ref to XStyleFamiliesSupplier is null.");
681  return;
682  }
683  uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamSupp->getStyleFamilies();
684 
685  if (!xStyleFamilies.is())
686  return;
687 
688  uno::Reference<container::XNameAccess> xPageStyles(xStyleFamilies->getByName("PageStyles"),
689  uno::UNO_QUERY);
690 
691  if (!xPageStyles.is())
692  return;
693 
694  uno::Reference<css::style::XStyle> xEndnotePageStyle(xPageStyles->getByName("Endnote"),
695  uno::UNO_QUERY);
696 
697  if (!xEndnotePageStyle.is())
698  return;
699 
700  // Language-independent name of the "Default Style" is "Standard"
701  uno::Reference<css::style::XStyle> xDefaultPageStyle(xPageStyles->getByName("Standard"),
702  uno::UNO_QUERY);
703  if (!xDefaultPageStyle.is())
704  return;
705 
706  if (xEndnotePageStyle->isUserDefined() || !xEndnotePageStyle->isInUse())
707  return;
708 
709  uno::Reference<beans::XPropertySet> xEndnotePagePropSet(xPageStyles->getByName("Endnote"), uno::UNO_QUERY);
710  uno::Reference<beans::XPropertySet> xDefaultPagePropSet(xPageStyles->getByName("Standard"), uno::UNO_QUERY);
711 
712  if (!xEndnotePagePropSet.is() || !xDefaultPagePropSet.is())
713  {
714  SAL_WARN("sw.ui", "xEndnotePagePropSet or xDefaultPagePropSet is null.");
715  return;
716  }
717 
718  auto const bIsDefLandScape = *o3tl::doAccess<bool>(
719  xDefaultPagePropSet->getPropertyValue("IsLandscape"));
720  auto const bIsEndLandScape = *o3tl::doAccess<bool>(
721  xEndnotePagePropSet->getPropertyValue("IsLandscape"));
722 
723  if (bIsDefLandScape == bIsEndLandScape)
724  return;
725 
726  auto const nWidth = xEndnotePagePropSet->getPropertyValue("Width");
727  auto const nHeight = xEndnotePagePropSet->getPropertyValue("Height");
728 
729  xEndnotePagePropSet->setPropertyValue("IsLandscape", css::uno::toAny(bIsDefLandScape));
730  xEndnotePagePropSet->setPropertyValue("Width", nHeight);
731  xEndnotePagePropSet->setPropertyValue("Height", nWidth);
732 }
733 }
734 
736  const OUString &rName,
737  const OUString &rParent,
738  const SfxStyleFamily nFamily,
739  SfxStyleSearchBits nMask,
740  const bool bNew,
741  const OString& sPage,
742  SwWrtShell* pActShell,
743  SfxRequest* pReq,
744  sal_uInt16 nSlot)
745 {
746  assert( GetWrtShell() );
747  const bool bBasic = pReq && pReq->IsAPI();
748  SfxStyleSheetBase *pStyle = nullptr;
749 
750  bool bModified = m_xDoc->getIDocumentState().IsModified();
751 
752  SwUndoId nNewStyleUndoId(SwUndoId::EMPTY);
753 
754  if( bNew )
755  {
756  if (!bBasic)
757  {
758  // start undo action in order to get only one undo action for the
759  // UI new style + change style operations
761  }
762 
763  if( SfxStyleSearchBits::All != nMask && SfxStyleSearchBits::AllVisible != nMask && SfxStyleSearchBits::Used != nMask )
764  nMask |= SfxStyleSearchBits::UserDefined;
765  else
766  nMask = SfxStyleSearchBits::UserDefined;
767 
768  if ( nFamily == SfxStyleFamily::Para || nFamily == SfxStyleFamily::Char || nFamily == SfxStyleFamily::Frame )
769  {
770  // Prevent undo append from being done during paragraph, character, and frame style Make
771  // Do it after ok return from style dialog when derived from style is known
772  ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
773  pStyle = &m_xBasePool->Make( rName, nFamily, nMask );
774  }
775  else
776  {
777  pStyle = &m_xBasePool->Make( rName, nFamily, nMask );
778  }
779 
780  // set the current one as Parent
781  SwDocStyleSheet* pDStyle = static_cast<SwDocStyleSheet*>(pStyle);
782  switch( nFamily )
783  {
784  case SfxStyleFamily::Para:
785  {
786  if(!rParent.isEmpty())
787  {
789  if(!pColl)
790  {
792  if(USHRT_MAX != nId)
793  pColl = m_pWrtShell->GetTextCollFromPool( nId );
794  }
795  pDStyle->GetCollection()->SetDerivedFrom( pColl );
796  pDStyle->PresetParent( rParent );
797 
798  /*When a new paragraph style is created based on a "to outline style
799  assigned" paragraph style, the outline level attribute and the list
800  style attribute of the new paragraph style have to be set to 0
801  respectively "".*/
802  if (pColl && pColl->IsAssignedToListLevelOfOutlineStyle())
803  {
804  SwNumRuleItem aItem;
805  pDStyle->GetCollection()->SetFormatAttr( aItem );
806  pDStyle->GetCollection()->SetAttrOutlineLevel( 0 );
807  }
808  }
809  else
810  {
812  pDStyle->GetCollection()->SetDerivedFrom( pColl );
813  if( pColl )
814  pDStyle->PresetParent( pColl->GetName() );
815  }
816  }
817  break;
818  case SfxStyleFamily::Char:
819  {
820  if(!rParent.isEmpty())
821  {
822  SwCharFormat* pCFormat = m_pWrtShell->FindCharFormatByName(rParent);
823  if(!pCFormat)
824  {
826  if(USHRT_MAX != nId)
827  pCFormat = m_pWrtShell->GetCharFormatFromPool( nId );
828  }
829 
830  pDStyle->GetCharFormat()->SetDerivedFrom( pCFormat );
831  pDStyle->PresetParent( rParent );
832  }
833  else
834  {
836  pDStyle->GetCharFormat()->SetDerivedFrom( pCFormat );
837  if( pCFormat )
838  pDStyle->PresetParent( pCFormat->GetName() );
839  }
840  }
841  break;
842  case SfxStyleFamily::Frame :
843  {
844  if(!rParent.isEmpty())
845  {
846  SwFrameFormat* pFFormat = m_pWrtShell->GetDoc()->FindFrameFormatByName( rParent );
847  if(!pFFormat)
848  {
850  if(USHRT_MAX != nId)
851  pFFormat = m_pWrtShell->GetFrameFormatFromPool( nId );
852  }
853  pDStyle->GetFrameFormat()->SetDerivedFrom( pFFormat );
854  pDStyle->PresetParent( rParent );
855  }
856  }
857  break;
858  default: break;
859  }
860 
861  if (!bBasic)
862  {
863  //Get the undo id for the type of style that was created in order to re-use that comment for the grouped
864  //create style + change style operations
865  m_pWrtShell->GetLastUndoInfo(nullptr, &nNewStyleUndoId);
866  }
867  }
868  else
869  {
870  pStyle = m_xBasePool->Find( rName, nFamily );
871  SAL_WARN_IF( !pStyle, "sw.ui", "Style not found" );
872  }
873 
874  if(!pStyle)
875  return;
876 
877  // put dialogues together
878  rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pStyle) ) );
879  if( SfxStyleFamily::Para == nFamily )
880  {
881  SfxItemSet& rSet = xTmp->GetItemSet();
882  ::SwToSfxPageDescAttr( rSet );
883  // merge list level indent attributes into the item set if needed
884  xTmp->MergeIndentAttrsOfListStyle( rSet );
885 
886  ::ConvertAttrCharToGen(xTmp->GetItemSet(), /*bIsPara=*/true);
887  }
888  else if( SfxStyleFamily::Char == nFamily )
889  {
890  ::ConvertAttrCharToGen(xTmp->GetItemSet());
891  }
892 
893  if(SfxStyleFamily::Page == nFamily || SfxStyleFamily::Para == nFamily)
894  {
895  // create needed items for XPropertyList entries from the DrawModel so that
896  // the Area TabPage can access them
897  SfxItemSet& rSet = xTmp->GetItemSet();
898  const SwDrawModel* pDrawModel = GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
899 
900  rSet.Put(SvxColorListItem(pDrawModel->GetColorList(), SID_COLOR_TABLE));
901  rSet.Put(SvxGradientListItem(pDrawModel->GetGradientList(), SID_GRADIENT_LIST));
902  rSet.Put(SvxHatchListItem(pDrawModel->GetHatchList(), SID_HATCH_LIST));
903  rSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapList(), SID_BITMAP_LIST));
904  rSet.Put(SvxPatternListItem(pDrawModel->GetPatternList(), SID_PATTERN_LIST));
905 
906  std::optional<SfxGrabBagItem> oGrabBag;
907  SfxPoolItem const* pItem(nullptr);
908  if (SfxItemState::SET == rSet.GetItemState(SID_ATTR_CHAR_GRABBAG, true, &pItem))
909  {
910  oGrabBag.emplace(*static_cast<SfxGrabBagItem const*>(pItem));
911  }
912  else
913  {
914  oGrabBag.emplace(SID_ATTR_CHAR_GRABBAG);
915  }
916  bool bGutterAtTop
918  oGrabBag->GetGrabBag()["GutterAtTop"] <<= bGutterAtTop;
919  rSet.Put(*oGrabBag);
920  }
921 
922  if (!bBasic)
923  {
924  // prior to the dialog the HtmlMode at the DocShell is being sunk
925  sal_uInt16 nHtmlMode = ::GetHtmlMode(this);
926 
927  // In HTML mode, we do not always have a printer. In order to show
928  // the correct page size in the Format - Page dialog, we have to
929  // get one here.
930  SwWrtShell* pCurrShell = pActShell ? pActShell : m_pWrtShell;
931  if( ( HTMLMODE_ON & nHtmlMode ) &&
932  !pCurrShell->getIDocumentDeviceAccess().getPrinter( false ) )
933  pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess().getPrinter( true ) );
934 
935  PutItem(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
936  FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode));
937  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
940  *xTmp, nFamily, sPage, pCurrShell, bNew));
941  auto pApplyStyleHelper = std::make_shared<ApplyStyle>(*this, bNew, xTmp, nFamily, pDlg.get(), m_xBasePool, bModified);
942  pDlg->SetApplyHdl(LINK(pApplyStyleHelper.get(), ApplyStyle, ApplyHdl));
943 
944  std::shared_ptr<SfxRequest> pRequest;
945  if (pReq)
946  {
947  pRequest = std::make_shared<SfxRequest>(*pReq);
948  pReq->Ignore(); // the 'old' request is not relevant any more
949  }
950 
951  bool bIsDefaultPage = nFamily == SfxStyleFamily::Page
952  && rName == SwResId(STR_POOLPAGE_STANDARD)
953  && pStyle->IsUsed()
954  && !pStyle->IsUserDefined();
955 
956  pDlg->StartExecuteAsync([bIsDefaultPage, bNew, nFamily, nSlot, nNewStyleUndoId, pApplyStyleHelper, pRequest, xTmp, this](sal_Int32 nResult){
957  if (RET_OK == nResult)
958  pApplyStyleHelper->apply();
959 
960  if (bNew)
961  {
962  switch( nFamily )
963  {
964  case SfxStyleFamily::Para:
965  {
966  if(!xTmp->GetParent().isEmpty())
967  {
968  SwTextFormatColl* pColl = m_pWrtShell->FindTextFormatCollByName(xTmp->GetParent());
970  {
972  std::make_unique<SwUndoTextFormatCollCreate>(xTmp->GetCollection(), pColl, *GetDoc()));
973  }
974  }
975  }
976  break;
977  case SfxStyleFamily::Char:
978  {
979  if(!xTmp->GetParent().isEmpty())
980  {
981  SwCharFormat* pCFormat = m_pWrtShell->FindCharFormatByName(xTmp->GetParent());
983  {
985  std::make_unique<SwUndoCharFormatCreate>(xTmp->GetCharFormat(), pCFormat, *GetDoc()));
986  }
987  }
988  }
989  break;
990  case SfxStyleFamily::Frame:
991  {
992  if(!xTmp->GetParent().isEmpty())
993  {
994  SwFrameFormat* pFFormat = m_pWrtShell->GetDoc()->FindFrameFormatByName(xTmp->GetParent());
996  {
998  std::make_unique<SwUndoFrameFormatCreate>(xTmp->GetFrameFormat(), pFFormat, *GetDoc()));
999  }
1000  }
1001  }
1002  break;
1003  default: break;
1004  }
1005 
1006  SwRewriter aRewriter;
1007  aRewriter.AddRule(UndoArg1, xTmp->GetName());
1008  //Group the create style and change style operations together under the
1009  //one "create style" comment
1010  m_pWrtShell->EndUndo(nNewStyleUndoId, &aRewriter);
1011  }
1012 
1013  bool bDocModified = pApplyStyleHelper->DocIsModified();
1014 
1015  if (RET_OK != nResult)
1016  {
1017  if (bNew)
1018  {
1019  GetWrtShell()->Undo();
1020  m_xDoc->GetIDocumentUndoRedo().ClearRedo();
1021  }
1022 
1023  if (!bDocModified)
1024  m_xDoc->getIDocumentState().ResetModified();
1025  }
1026 
1027  // Update Watermark if new page style was created
1028  if (nSlot == SID_STYLE_NEW && nFamily == SfxStyleFamily::Page)
1029  {
1030  SwWrtShell* pShell = GetWrtShell();
1031  const SfxWatermarkItem aWatermark = pShell->GetWatermark();
1032  pShell->SetWatermark(aWatermark);
1033  }
1034 
1035  pApplyStyleHelper->m_pDlg.disposeAndClear();
1036  if (pRequest)
1037  pRequest->Done();
1038 
1039  if (bIsDefaultPage && bDocModified)
1040  {
1041  uno::Reference< style::XStyleFamiliesSupplier > xStyleFamSupp(GetModel(), uno::UNO_QUERY);
1042 
1043  if (!xStyleFamSupp.is())
1044  {
1045  SAL_WARN("sw.ui", "Ref to XStyleFamiliesSupplier is null.");
1046  return;
1047  }
1048 
1049  syncEndnoteOrientation(xStyleFamSupp);
1050  }
1051  });
1052  }
1053  else
1054  {
1055  // prior to the dialog the HtmlMode at the DocShell is being sunk
1056  PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(this)));
1057 
1059 
1060  if( SfxStyleFamily::Para == nFamily )
1061  {
1062  ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() );
1063  ::ConvertAttrGenToChar(xTmp->GetItemSet(), xTmp->GetItemSet(), /*bIsPara=*/true);
1064  }
1065  else
1066  {
1067  ::ConvertAttrGenToChar(xTmp->GetItemSet(), xTmp->GetItemSet());
1068  }
1069  if(SfxStyleFamily::Page == nFamily)
1071 
1072  if( bNew )
1073  m_xBasePool->Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetCreated, *xTmp));
1074 
1075  m_xDoc->getIDocumentState().SetModified();
1076  if( !bModified ) // Bug 57028
1077  {
1078  m_xDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
1079  }
1081  }
1082 }
1083 
1084 void SwDocShell::Delete(const OUString &rName, SfxStyleFamily nFamily)
1085 {
1086  SfxStyleSheetBase *pStyle = m_xBasePool->Find(rName, nFamily);
1087 
1088  if(pStyle)
1089  {
1090  assert( GetWrtShell() );
1091 
1093  m_xBasePool->Remove(pStyle);
1095  }
1096 }
1097 
1098 void SwDocShell::Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden)
1099 {
1100  SfxStyleSheetBase *pStyle = m_xBasePool->Find(rName, nFamily);
1101 
1102  if(pStyle)
1103  {
1104  assert( GetWrtShell() );
1105 
1107  rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *static_cast<SwDocStyleSheet*>(pStyle) ) );
1108  xTmp->SetHidden( bHidden );
1110  }
1111 }
1112 
1113 // apply template
1115  SwWrtShell* pShell, const sal_uInt16 nMode )
1116 {
1117  SwDocStyleSheet* pStyle = static_cast<SwDocStyleSheet*>( m_xBasePool->Find( rName, nFamily ) );
1118 
1119  SAL_WARN_IF( !pStyle, "sw.ui", "Style not found" );
1120 
1121  if(!pStyle)
1122  return SfxStyleFamily::None;
1123 
1124  SwWrtShell *pSh = pShell ? pShell : GetWrtShell();
1125 
1126  assert( pSh );
1127 
1128  pSh->StartAllAction();
1129 
1130  switch (nFamily)
1131  {
1132  case SfxStyleFamily::Char:
1133  {
1134  SwFormatCharFormat aFormat(pStyle->GetCharFormat());
1135  pSh->SetAttrItem( aFormat, (nMode & KEY_SHIFT) ?
1137  break;
1138  }
1139  case SfxStyleFamily::Para:
1140  {
1141  // #i62675#
1142  // clear also list attributes at affected text nodes, if paragraph
1143  // style has the list style attribute set.
1144  pSh->SetTextFormatColl( pStyle->GetCollection(), true );
1145  break;
1146  }
1147  case SfxStyleFamily::Frame:
1148  {
1149  if ( pSh->IsFrameSelected() )
1150  pSh->SetFrameFormat( pStyle->GetFrameFormat() );
1151  break;
1152  }
1153  case SfxStyleFamily::Page:
1154  {
1155  pSh->SetPageStyle(pStyle->GetPageDesc()->GetName());
1156  break;
1157  }
1158  case SfxStyleFamily::Pseudo:
1159  {
1160  // reset indent attribute on applying list style
1161  // continue list of list style
1162  const SwNumRule* pNumRule = pStyle->GetNumRule();
1163  if (pNumRule->GetName() == "No List")
1164  {
1166  break;
1167  }
1168  const OUString sListIdForStyle =pNumRule->GetDefaultListId();
1169  pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true );
1170  break;
1171  }
1172  case SfxStyleFamily::Table:
1173  {
1174  pSh->SetTableStyle(pStyle->GetName());
1175  break;
1176  }
1177  default:
1178  OSL_FAIL("Unknown family");
1179  }
1180  pSh->EndAllAction();
1181 
1182  return nFamily;
1183 }
1184 
1185 // start watering-can
1187 {
1188  assert( GetWrtShell() );
1189 
1190  SwEditWin& rEdtWin = m_pView->GetEditWin();
1191  SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
1192  bool bWaterCan = !(pApply && pApply->eType != SfxStyleFamily(0));
1193 
1194  if( rName.isEmpty() )
1195  bWaterCan = false;
1196 
1197  SwApplyTemplate aTemplate;
1198  aTemplate.eType = nFamily;
1199 
1200  if(bWaterCan)
1201  {
1202  SwDocStyleSheet* pStyle =
1203  static_cast<SwDocStyleSheet*>( m_xBasePool->Find(rName, nFamily) );
1204 
1205  SAL_WARN_IF( !pStyle, "sw.ui", "Where's the StyleSheet" );
1206 
1207  if(!pStyle) return nFamily;
1208 
1209  switch(nFamily)
1210  {
1211  case SfxStyleFamily::Char:
1212  aTemplate.aColl.pCharFormat = pStyle->GetCharFormat();
1213  break;
1214  case SfxStyleFamily::Para:
1215  aTemplate.aColl.pTextColl = pStyle->GetCollection();
1216  break;
1217  case SfxStyleFamily::Frame:
1218  aTemplate.aColl.pFrameFormat = pStyle->GetFrameFormat();
1219  break;
1220  case SfxStyleFamily::Page:
1221  aTemplate.aColl.pPageDesc = const_cast<SwPageDesc*>(pStyle->GetPageDesc());
1222  break;
1223  case SfxStyleFamily::Pseudo:
1224  aTemplate.aColl.pNumRule = const_cast<SwNumRule*>(pStyle->GetNumRule());
1225  break;
1226 
1227  default:
1228  OSL_FAIL("Unknown family");
1229  }
1230  }
1231  else
1232  aTemplate.eType = SfxStyleFamily(0);
1233 
1234  m_pView->GetEditWin().SetApplyTemplate(aTemplate);
1235 
1236  return nFamily;
1237 }
1238 
1239 // update template
1240 void SwDocShell::UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWrtShell* pShell)
1241 {
1242  SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
1243  assert( pCurrWrtShell );
1244 
1245  SwDocStyleSheet* pStyle =
1246  static_cast<SwDocStyleSheet*>( m_xBasePool->Find(rName, nFamily) );
1247 
1248  if (!pStyle)
1249  return;
1250 
1251  switch(nFamily)
1252  {
1253  case SfxStyleFamily::Para:
1254  {
1255  SwTextFormatColl* pColl = pStyle->GetCollection();
1256  if(pColl && !pColl->IsDefault())
1257  {
1259 
1260  SwRewriter aRewriter;
1261  aRewriter.AddRule(UndoArg1, pColl->GetName());
1262 
1263  GetWrtShell()->StartUndo(SwUndoId::INSFMTATTR, &aRewriter);
1264  GetWrtShell()->FillByEx(pColl);
1265  // also apply template to remove hard set attributes
1266  GetWrtShell()->SetTextFormatColl( pColl );
1267  GetWrtShell()->EndUndo();
1269  }
1270  break;
1271  }
1272  case SfxStyleFamily::Frame:
1273  {
1274  SwFrameFormat* pFrame = pStyle->GetFrameFormat();
1275  if( pCurrWrtShell->IsFrameSelected() && pFrame && !pFrame->IsDefault() )
1276  {
1278  pCurrWrtShell->StartAllAction();
1279  pCurrWrtShell->GetFlyFrameAttr( aSet );
1280 
1281  // #i105535#
1282  // no update of anchor attribute
1283  aSet.ClearItem( RES_ANCHOR );
1284 
1285  pFrame->SetFormatAttr( aSet );
1286 
1287  // also apply template to remove hard set attributes
1288  pCurrWrtShell->SetFrameFormat( pFrame, true );
1289  pCurrWrtShell->EndAllAction();
1290  }
1291  }
1292  break;
1293  case SfxStyleFamily::Char:
1294  {
1295  SwCharFormat* pChar = pStyle->GetCharFormat();
1296  if( pChar && !pChar->IsDefault() )
1297  {
1298  pCurrWrtShell->StartAllAction();
1299  pCurrWrtShell->FillByEx(pChar);
1300  // also apply template to remove hard set attributes
1301  pCurrWrtShell->EndAllAction();
1302  }
1303 
1304  }
1305  break;
1306  case SfxStyleFamily::Pseudo:
1307  {
1308  const SwNumRule* pCurRule;
1309  if( pStyle->GetNumRule() &&
1310  nullptr != ( pCurRule = pCurrWrtShell->GetNumRuleAtCurrCursorPos() ))
1311  {
1312  SwNumRule aRule( *pCurRule );
1313  // #i91400#
1314  aRule.SetName( pStyle->GetNumRule()->GetName(),
1315  pCurrWrtShell->GetDoc()->getIDocumentListsAccess() );
1316  pCurrWrtShell->ChgNumRuleFormats( aRule );
1317  }
1318  }
1319  break;
1320  case SfxStyleFamily::Table:
1321  {
1322 
1323  SwTableAutoFormat aFormat(rName);
1324  if (pCurrWrtShell->GetTableAutoFormat(aFormat))
1325  {
1326  pCurrWrtShell->StartAllAction();
1327  pCurrWrtShell->GetDoc()->ChgTableStyle(rName, aFormat);
1328  pCurrWrtShell->EndAllAction();
1329  }
1330 
1331  }
1332  break;
1333  default: break;
1334  }
1335 
1336  m_xDoc->BroadcastStyleOperation(rName, nFamily, SfxHintId::StyleSheetModified);
1337 }
1338 
1339 // NewByExample
1340 void SwDocShell::MakeByExample( const OUString &rName, SfxStyleFamily nFamily,
1341  SfxStyleSearchBits nMask, SwWrtShell* pShell )
1342 {
1343  SwWrtShell* pCurrWrtShell = pShell ? pShell : GetWrtShell();
1344  SwDocStyleSheet* pStyle = static_cast<SwDocStyleSheet*>( m_xBasePool->Find(
1345  rName, nFamily ) );
1346  if(!pStyle)
1347  {
1348  // preserve the current mask of PI, then the new one is
1349  // immediately merged with the viewable area
1350  if( SfxStyleSearchBits::All == nMask || SfxStyleSearchBits::Used == nMask )
1351  nMask = SfxStyleSearchBits::UserDefined;
1352  else
1353  nMask |= SfxStyleSearchBits::UserDefined;
1354 
1355  if (nFamily == SfxStyleFamily::Para || nFamily == SfxStyleFamily::Char || nFamily == SfxStyleFamily::Frame)
1356  {
1357  // Prevent undo append from being done during paragraph, character, and frame style Make. Do it later
1358  ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
1359  pStyle = static_cast<SwDocStyleSheet*>(&m_xBasePool->Make(rName, nFamily, nMask));
1360  }
1361  else
1362  {
1363  pStyle = static_cast<SwDocStyleSheet*>(&m_xBasePool->Make(rName, nFamily, nMask));
1364  }
1365  }
1366 
1367  switch(nFamily)
1368  {
1369  case SfxStyleFamily::Para:
1370  {
1371  SwTextFormatColl* pColl = pStyle->GetCollection();
1372  if(pColl && !pColl->IsDefault())
1373  {
1374  pCurrWrtShell->StartAllAction();
1375  pCurrWrtShell->FillByEx(pColl);
1376  // also apply template to remove hard set attributes
1377  SwTextFormatColl * pDerivedFrom = pCurrWrtShell->GetCurTextFormatColl();
1378  pColl->SetDerivedFrom(pDerivedFrom);
1379 
1380  // set the mask at the Collection:
1381  sal_uInt16 nId = pColl->GetPoolFormatId() & 0x87ff;
1382  switch( nMask & static_cast<SfxStyleSearchBits>(0x0fff) )
1383  {
1384  case SfxStyleSearchBits::SwText:
1385  nId |= COLL_TEXT_BITS;
1386  break;
1387  case SfxStyleSearchBits::SwChapter:
1388  nId |= COLL_DOC_BITS;
1389  break;
1390  case SfxStyleSearchBits::SwList:
1391  nId |= COLL_LISTS_BITS;
1392  break;
1393  case SfxStyleSearchBits::SwIndex:
1394  nId |= COLL_REGISTER_BITS;
1395  break;
1396  case SfxStyleSearchBits::SwExtra:
1397  nId |= COLL_EXTRA_BITS;
1398  break;
1399  case SfxStyleSearchBits::SwHtml:
1400  nId |= COLL_HTML_BITS;
1401  break;
1402  default: break;
1403  }
1404  pColl->SetPoolFormatId(nId);
1405 
1406  if (GetDoc()->GetIDocumentUndoRedo().DoesUndo())
1407  {
1409  std::make_unique<SwUndoTextFormatCollCreate>(pColl, pDerivedFrom, *GetDoc()));
1410  }
1411  pCurrWrtShell->SetTextFormatColl(pColl);
1412  pCurrWrtShell->EndAllAction();
1413  }
1414  }
1415  break;
1416  case SfxStyleFamily::Frame:
1417  {
1418  SwFrameFormat* pFrame = pStyle->GetFrameFormat();
1419  if(pCurrWrtShell->IsFrameSelected() && pFrame && !pFrame->IsDefault())
1420  {
1421  pCurrWrtShell->StartAllAction();
1422 
1424  pCurrWrtShell->GetFlyFrameAttr( aSet );
1425  aSet.ClearItem(RES_ANCHOR); // tdf#112574 no anchor in styles
1426 
1427  SwFrameFormat* pFFormat = pCurrWrtShell->GetSelectedFrameFormat();
1428  pFrame->SetDerivedFrom( pFFormat );
1429  pFrame->SetFormatAttr( aSet );
1430  if (GetDoc()->GetIDocumentUndoRedo().DoesUndo())
1431  {
1433  std::make_unique<SwUndoFrameFormatCreate>(pFrame, pFFormat, *GetDoc()));
1434  }
1435  // also apply template to remove hard set attributes
1436  pCurrWrtShell->SetFrameFormat(pFrame);
1437  pCurrWrtShell->EndAllAction();
1438  }
1439  }
1440  break;
1441  case SfxStyleFamily::Char:
1442  {
1443  SwCharFormat* pChar = pStyle->GetCharFormat();
1444  if(pChar && !pChar->IsDefault())
1445  {
1446  pCurrWrtShell->StartAllAction();
1447  pCurrWrtShell->FillByEx( pChar );
1448  SwCharFormat * pDerivedFrom = pCurrWrtShell->GetCurCharFormat();
1449  pChar->SetDerivedFrom( pDerivedFrom );
1450  SwFormatCharFormat aFormat( pChar );
1451 
1452  if (GetDoc()->GetIDocumentUndoRedo().DoesUndo())
1453  {
1454  // Looks like sometimes pDerivedFrom can be null and this is not supported by redo code
1455  // So use default format as a derived from in such situations
1457  std::make_unique<SwUndoCharFormatCreate>(
1458  pChar, pDerivedFrom ? pDerivedFrom : GetDoc()->GetDfltCharFormat(),
1459  *GetDoc()));
1460  }
1461  pCurrWrtShell->SetAttrItem(aFormat);
1462  pCurrWrtShell->EndAllAction();
1463  }
1464  }
1465  break;
1466 
1467  case SfxStyleFamily::Page:
1468  {
1469  pCurrWrtShell->StartAllAction();
1470  size_t nPgDsc = pCurrWrtShell->GetCurPageDesc();
1471  SwPageDesc& rSrc = const_cast<SwPageDesc&>(pCurrWrtShell->GetPageDesc( nPgDsc ));
1472  SwPageDesc& rDest = *const_cast<SwPageDesc*>(pStyle->GetPageDesc());
1473 
1474  sal_uInt16 nPoolId = rDest.GetPoolFormatId();
1475  sal_uInt16 nHId = rDest.GetPoolHelpId();
1476  sal_uInt8 nHFId = rDest.GetPoolHlpFileId();
1477 
1478  pCurrWrtShell->GetDoc()->CopyPageDesc( rSrc, rDest );
1479 
1480  // PoolId must NEVER be copied!
1481  rDest.SetPoolFormatId( nPoolId );
1482  rDest.SetPoolHelpId( nHId );
1483  rDest.SetPoolHlpFileId( nHFId );
1484 
1485  // when Headers/Footers are created, there is no Undo anymore!
1486  pCurrWrtShell->GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
1487 
1488  pCurrWrtShell->EndAllAction();
1489  }
1490  break;
1491 
1492  case SfxStyleFamily::Pseudo:
1493  {
1494  const SwNumRule* pCurRule = pCurrWrtShell->GetNumRuleAtCurrCursorPos();
1495 
1496  if (pCurRule)
1497  {
1498  pCurrWrtShell->StartAllAction();
1499 
1500  SwNumRule aRule( *pCurRule );
1501  OUString sOrigRule( aRule.GetName() );
1502  // #i91400#
1503  aRule.SetName( pStyle->GetNumRule()->GetName(),
1504  pCurrWrtShell->GetDoc()->getIDocumentListsAccess() );
1505  pCurrWrtShell->ChgNumRuleFormats( aRule );
1506 
1507  pCurrWrtShell->ReplaceNumRule( sOrigRule, aRule.GetName() );
1508 
1509  pCurrWrtShell->EndAllAction();
1510  }
1511  }
1512  break;
1513 
1514  case SfxStyleFamily::Table:
1515  {
1516  SwTableAutoFormat* pFormat = pStyle->GetTableFormat();
1517  if (pCurrWrtShell->GetTableAutoFormat(*pFormat))
1518  {
1519  pCurrWrtShell->StartAllAction();
1520 
1521  pCurrWrtShell->SetTableStyle(rName);
1522 
1523  pCurrWrtShell->EndAllAction();
1524  }
1525  }
1526  break;
1527 
1528  default: break;
1529  }
1530 
1531  m_xDoc->BroadcastStyleOperation(rName, nFamily, SfxHintId::StyleSheetCreated);
1532 }
1533 
1535 {
1536  sw::AccessibilityCheck aCheck(m_xDoc.get());
1537  aCheck.check();
1538  return aCheck.getIssueCollection();
1539 }
1540 
1541 std::set<Color> SwDocShell::GetDocColors()
1542 {
1543  return m_xDoc->GetDocColors();
1544 }
1545 
1547 {
1548  LoadStyles_(rSource, false);
1549 }
1550 
1551 // bPreserveCurrentDocument determines whether SetFixFields() is called
1552 // This call modifies the source document. This mustn't happen when the source
1553 // is a document the user is working on.
1554 // Calls of ::LoadStyles() normally use files especially loaded for the purpose
1555 // of importing styles.
1556 void SwDocShell::LoadStyles_( SfxObjectShell& rSource, bool bPreserveCurrentDocument )
1557 {
1558 /* [Description]
1559 
1560  This method is called by SFx if Styles have to be reloaded from a
1561  document-template. Existing Styles should be overwritten by that.
1562  That's why the document has to be reformatted. Therefore applications
1563  will usually override this method and call the baseclass' implementation
1564  in their implementation.
1565 */
1566  // When the source is our document, we do the checking ourselves
1567  // (much quicker and doesn't use the crutch StxStylePool).
1568  if( dynamic_cast<const SwDocShell*>( &rSource) != nullptr)
1569  {
1570  // in order for the Headers/Footers not to get the fixed content
1571  // of the template, update all the Source's
1572  // FixFields once.
1573  if(!bPreserveCurrentDocument)
1574  static_cast<SwDocShell&>(rSource).m_xDoc->getIDocumentFieldsAccess().SetFixFields(nullptr);
1575  if (m_pWrtShell)
1576  {
1577  // rhbz#818557, fdo#58893: EndAllAction will call SelectShell(),
1578  // which pushes a bunch of SfxShells that are not cleared
1579  // (for unknown reasons) when closing the document, causing crash;
1580  // setting g_bNoInterrupt appears to avoid the problem.
1583  m_xDoc->ReplaceStyles( *static_cast<SwDocShell&>(rSource).m_xDoc );
1585  }
1586  else
1587  {
1588  bool bModified = m_xDoc->getIDocumentState().IsModified();
1589  m_xDoc->ReplaceStyles( *static_cast<SwDocShell&>(rSource).m_xDoc );
1590  if (!bModified && m_xDoc->getIDocumentState().IsModified() && !m_pView)
1591  {
1592  // the View is created later, but overwrites the Modify-Flag.
1593  // Undo doesn't work anymore anyways.
1594  m_xDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
1595  }
1596  }
1597  }
1598  else
1599  SfxObjectShell::LoadStyles( rSource );
1600 }
1601 
1603  const OUString& rPage,
1604  const OString& rPageId,
1605  SwWrtShell& rActShell,
1606  SfxRequest* pRequest)
1607 {
1608  Edit(rPage, OUString(), SfxStyleFamily::Page, SfxStyleSearchBits::Auto, false, rPageId, &rActShell, pRequest);
1609 }
1610 
1611 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
bool IsPrintLayoutExtension() const
virtual bool IsUsed() const
FieldUnit
SwTextFormatColl * GetCurTextFormatColl() const
Get the named paragraph format of the current selection.
Definition: edattr.cxx:246
SwTextFormatColl * FindTextFormatCollByName(std::u16string_view rName) const
Definition: edfmt.cxx:154
const sal_uInt16 COLL_LISTS_BITS
Definition: poolfmt.hxx:66
const sal_uInt16 COLL_DOC_BITS
Definition: poolfmt.hxx:69
IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone *, void)
Definition: docst.cxx:576
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:123
void SwToSfxPageDescAttr(SfxItemSet &rSet)
Definition: uitool.cxx:686
SfxWatermarkItem GetWatermark() const
Definition: edfcol.cxx:1381
bool IsDefault() const
Definition: format.hxx:113
SwTableAutoFormat * GetTableFormat()
Definition: docstyle.cxx:2190
SfxStyleFamily eType
Definition: view.hxx:116
SwUndoId
Definition: swundo.hxx:29
void SetPoolHelpId(sal_uInt16 const nId)
Definition: pagedesc.hxx:279
std::string GetValue
const SwNumRule * GetNumRuleAtCurrCursorPos() const
Definition: ednumber.cxx:774
SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)
Definition: editsh.hxx:356
SfxDispatcher * GetDispatcher()
virtual void SetModified()=0
Must be called manually at changes of format.
SW_DLLPUBLIC void ConvertAttrCharToGen(SfxItemSet &rSet, bool bPara=false)
Convert character specific attributes to general ones used by tab pages.
Definition: uitool.cxx:104
bool GetLastUndoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const
Definition: edws.cxx:237
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
const OUString & GetDefaultListId() const
Definition: numrule.hxx:195
sal_Int64 n
const sal_uInt16 COLL_HTML_BITS
Definition: poolfmt.hxx:70
Definition: doc.hxx:187
SAL_DLLPRIVATE void UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWrtShell *pShell)
Definition: docst.cxx:1240
sal_uInt16 GetValue() const
void InvalidateItem(sal_uInt16 nWhich)
sal_Int16 nId
sal_uInt16 FirstWhich()
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
const OUString & GetName() const
Definition: numrule.hxx:225
SwEditWin & GetEditWin()
Definition: view.hxx:416
void Done(bool bRemove=false)
void SetPageStyle(const OUString &rCollName)
Definition: wrtsh1.cxx:1548
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
css::uno::Reference< css::frame::XModel > GetModel() const
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
void SfxToSwPageDescAttr(const SwWrtShell &rShell, SfxItemSet &rSet)
Definition: uitool.cxx:625
virtual bool SetFormatAttr(const SfxPoolItem &rAttr) override
Override to recognize changes on the and register/unregister the paragragh style at t...
Definition: fmtcol.cxx:339
SwFrameFormat * GetFrameFormatFromPool(sal_uInt16 nId)
Definition: editsh.hxx:354
SwFrameFormat * FindFrameFormatByName(std::u16string_view rName) const
Definition: docfmt.cxx:734
void PutItem(const SfxPoolItem &rItem)
void SetValue(SfxStyleSearchBits n)
void EndAllAction()
Definition: edws.cxx:97
void SetApplyTemplate(const SwApplyTemplate &)
Apply template.
Definition: edtwin.cxx:5118
SwPageDesc * pPageDesc
Definition: view.hxx:110
sal_uInt16 NextWhich()
XPatternListRef GetPatternList() const
const OUString & GetName() const
Definition: pagedesc.hxx:197
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
void SetCurNumRule(const SwNumRule &, const bool bCreateNewList, const OUString &sContinuedListId=OUString(), const bool bResetIndentAttrs=false)
Optional parameter (default value false).
Definition: ednumber.cxx:818
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
void SetWatermark(const SfxWatermarkItem &rText)
Definition: edfcol.cxx:1606
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
void FillByEx(SwCharFormat *)
Definition: edfmt.cxx:53
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:114
const SwView & GetView() const
Definition: wrtsh.hxx:429
const OUString & GetName() const
#define FN_NUM_BULLET_OFF
Definition: cmdid.h:89
void SetPoolFormatId(sal_uInt16 nId)
Definition: format.hxx:148
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat-Id.
Definition: pagedesc.hxx:276
void ExecStyleSheet(SfxRequest &)
Definition: docst.cxx:287
SAL_DLLPRIVATE void Edit(const OUString &rName, const OUString &rParent, const SfxStyleFamily nFamily, SfxStyleSearchBits nMask, const bool bNew, const OString &sPageId, SwWrtShell *pActShell, SfxRequest *pRequest=nullptr, sal_uInt16 nSlot=0)
Methods for StyleSheets.
Definition: docst.cxx:735
bool SetTableStyle(const OUString &rStyleName)
Set table style of the current table.
Definition: fetab.cxx:1172
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2010
const OUString & GetName() const
Definition: format.hxx:115
virtual void DelAllUndoObj()=0
Delete all Undo actions.
void InitPrt(OutputDevice *pOutDev)
Definition: vprint.cxx:176
SwFrameFormat * GetFrameFormat()
Definition: docstyle.cxx:2229
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
OUString GetName() const
const SwTable & GetTable() const
Definition: node.hxx:501
void SetPoolHlpFileId(sal_uInt8 const nId)
Definition: pagedesc.hxx:281
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
const SwPageDesc * GetPageDesc()
Definition: docstyle.cxx:2169
const OUString & GetTableStyleName() const
Return the table style name of this table.
Definition: swtable.hxx:190
SfxStyleFamily
const SwTOXBase * GetCurTOX() const
Get current listing before or at the Cursor.
Definition: edtox.cxx:187
virtual void LoadStyles(SfxObjectShell &rSource) override
Definition: docst.cxx:1546
const sal_uInt16 COLL_REGISTER_BITS
Definition: poolfmt.hxx:68
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2155
virtual bool DoesUndo() const =0
Is Undo enabled?
const char * sName
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:321
void PresetParent(const OUString &rName)
Definition: docstyle.hxx:119
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:147
SfxItemPool & GetPool() const
static SvxHtmlOptions & Get()
void ChgNumRuleFormats(const SwNumRule &rRule)
Definition: ednumber.cxx:868
bool GetFlyFrameAttr(SfxItemSet &rSet) const
Definition: fefly1.cxx:1038
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2663
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
const SwTableNode * IsCursorInTable() const
Definition: crsrsh.hxx:889
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
void SetTextFormatColl(SwTextFormatColl *, const bool bResetListAttrs=false)
Add 2nd optional parameter - see also
Definition: edfcol.cxx:2190
Style of a layout element.
Definition: frmfmt.hxx:58
SwApplyTemplate * GetApplyTemplate() const
Definition: edtwin.hxx:233
#define SW_MOD()
Definition: swmodule.hxx:255
#define FN_INSERT_CTRL
Definition: cmdid.h:253
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:726
SwTextFormatColl * pTextColl
Definition: view.hxx:109
SwNumRule * pNumRule
Definition: view.hxx:113
sfx::AccessibilityIssueCollection runAccessibilityCheck() override
Definition: docst.cxx:1534
virtual void SetUndoNoResetModified()=0
Disable (re)setting the document modified flag on Undo/Redo.
sal_uInt16 GetModifier() const
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
void LoadStyles_(SfxObjectShell &rSource, bool bPreserveCurrentDocument)
Definition: docst.cxx:1556
virtual std::set< Color > GetDocColors() override
Definition: docst.cxx:1541
SfxBindings & GetBindings()
#define FN_PARAM_WRTSHELL
Definition: cmdid.h:795
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:112
const OUString & GetValue() const
sal_uInt16 Count() const
const SwPageDesc & GetPageDesc(size_t i) const
Definition: fedesc.cxx:126
HTMLMODE_ON
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:354
const T * GetArg(sal_uInt16 nSlotId) const
void ChgTableStyle(const OUString &rName, const SwTableAutoFormat &rNewFormat)
Definition: ndtbl.cxx:4635
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1140
XGradientListRef GetGradientList() const
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:27
const std::map< OUString, css::uno::Any > & GetGrabBag() const
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:224
SwFrameFormat * pFrameFormat
Definition: view.hxx:111
const SwNumRule * GetNumRule()
Definition: docstyle.cxx:2176
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
SfxItemState QueryState(sal_uInt16 nSID, std::unique_ptr< SfxPoolItem > &rpState)
rtl::Reference< SwDoc > m_xDoc
Document.
Definition: docsh.hxx:71
OUString SwResId(const char *pId)
Definition: swmodule.cxx:166
void SetPoolFormatId(sal_uInt16 const nId)
Definition: pagedesc.hxx:277
SW_DLLPUBLIC void ConvertAttrGenToChar(SfxItemSet &rSet, const SfxItemSet &rOrigSet, bool bPara=false)
Convert general attributes to the corresponding character attributes.
Definition: uitool.cxx:141
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
virtual void LoadStyles(SfxObjectShell &rSource)
SwFrameFormat * GetSelectedFrameFormat() const
If frame then frame style, else 0.
Definition: fefly1.cxx:1191
rtl::Reference< SfxStyleSheetBasePool > m_xBasePool
Passing through for formats.
Definition: docsh.hxx:72
sal_uInt16 const aFrameFormatSetRange[]
Definition: init.cxx:233
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
void SetReturnValue(const SfxPoolItem &)
SwCharFormat * pCharFormat
Definition: view.hxx:112
SAL_DLLPRIVATE void MakeByExample(const OUString &rName, SfxStyleFamily nFamily, SfxStyleSearchBits nMask, SwWrtShell *pShell)
Definition: docst.cxx:1340
SAL_DLLPRIVATE void Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden)
Definition: docst.cxx:1098
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void CopyPageDesc(const SwPageDesc &rSrcDesc, SwPageDesc &rDstDesc, bool bCopyPoolIds=true)
Copy the complete PageDesc - beyond document and "deep"! Optionally copying of PoolFormatId, -HlpId can be prevented.
Definition: docfmt.cxx:1416
static SfxViewFrame * Current()
XHatchListRef GetHatchList() const
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2162
void DisableItem(sal_uInt16 nWhich)
SwView * m_pView
For "historical reasons" nothing can be done without the WrtShell.
Definition: docsh.hxx:83
void ReplaceNumRule(const OUString &rOldRule, const OUString &rNewRule)
Definition: ednumber.cxx:875
#define SAL_WARN_IF(condition, area, stream)
unsigned char sal_uInt8
OUString aUIName
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
OUString aName
RET_OK
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:176
SwWrtShell * m_pWrtShell
Definition: docsh.hxx:84
sal_uInt16 GetPoolHelpId() const
Definition: pagedesc.hxx:278
SwCharFormat * FindCharFormatByName(std::u16string_view rName) const
Definition: edfmt.cxx:149
void SetAttrOutlineLevel(int)
Definition: fmtcol.cxx:587
const char * pChar
void InvalidateRulerPos()
Definition: viewport.cxx:105
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
void SetFrameFormat(SwFrameFormat *pFormat, bool bKeepOrient=false, Point const *pDocPos=nullptr)
If frame then set frame style.
Definition: fefly1.cxx:1201
XBitmapListRef GetBitmapList() const
sal_uInt8 GetPoolHlpFileId() const
Definition: pagedesc.hxx:280
bool IsUserDefined() const
reference_type * get() const
SAL_DLLPRIVATE SfxStyleFamily ApplyStyles(const OUString &rName, const SfxStyleFamily nFamily, SwWrtShell *pShell, sal_uInt16 nMode)
Definition: docst.cxx:1114
SwCharFormat * GetCurCharFormat() const
Definition: edfmt.cxx:40
bool g_bNoInterrupt
Definition: swmodule.cxx:115
void AppendItem(const SfxPoolItem &)
#define SAL_WARN(area, stream)
Reference< XModel > xModel
SAL_DLLPRIVATE SfxStyleFamily DoWaterCan(const OUString &rName, SfxStyleFamily nFamily)
Definition: docst.cxx:1186
bool IsAPI() const
const SwView * GetView() const
Definition: docsh.hxx:220
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
#define FN_INSERT_OBJ_CTRL
Definition: cmdid.h:254
const sal_uInt16 COLL_TEXT_BITS
Definition: poolfmt.hxx:65
XColorListRef GetColorList() const
static OUString GenerateUnusedName(SfxStyleSheetBasePool &rPool, SfxStyleFamily eFam)
void FormatPage(const OUString &rPage, const OString &rPageId, SwWrtShell &rActShell, SfxRequest *pRequest=nullptr)
Show page style format dialog.
Definition: docst.cxx:1602
void SetName(const OUString &rNm, IDocumentListsAccess &rDocListAccess)
Definition: number.cxx:103
constexpr sal_uInt16 KEY_SHIFT
union SwApplyTemplate::@32 aColl
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
SAL_DLLPRIVATE void Delete(const OUString &rName, SfxStyleFamily nFamily)
Definition: docst.cxx:1084
IDocumentListsAccess const & getIDocumentListsAccess() const
Definition: doc.cxx:293
size_t GetCurPageDesc(const bool bCalcFrame=true) const
Definition: fedesc.cxx:167
void StateStyleSheet(SfxItemSet &, SwWrtShell *pSh=nullptr)
Definition: docst.cxx:85
void Undo(sal_uInt16 const nCount=1)
Definition: edundo.cxx:97
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:237
bool IsFrameSelected() const
Definition: feshview.cxx:1158
SfxStyleSearchBits
Definition: view.hxx:144
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const sal_uInt16 COLL_EXTRA_BITS
Definition: poolfmt.hxx:67
static void DoUpdateAllCharts(SwDoc *pDoc)
Definition: unochart.cxx:50
bool GetTableAutoFormat(SwTableAutoFormat &rGet)
Definition: fetab.cxx:1248
virtual VclPtr< SfxAbstractApplyTabDialog > CreateTemplateDialog(weld::Window *pParent, SfxStyleSheetBase &rBase, SfxStyleFamily nRegion, const OString &sPage, SwWrtShell *pActShell, bool bNew)=0