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