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