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