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