tdf#146549 sw: Make the formatting toolbar visible
[LibreOffice.git] / sd / source / ui / dlg / dlgolbul.cxx
blobd09991fdca874b821d0ed9c9de05871e9b3467cc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <memory>
21 #include <OutlineBulletDlg.hxx>
23 #include <svx/svxids.hrc>
24 #include <editeng/eeitem.hxx>
26 #include <editeng/numitem.hxx>
28 #include <tools/debug.hxx>
29 #include <svx/dialogs.hrc>
30 #include <svx/svdmark.hxx>
31 #include <View.hxx>
32 #include <svx/svdobj.hxx>
33 #include <svl/style.hxx>
34 #include <svl/intitem.hxx>
35 #include <drawdoc.hxx>
37 #include <strings.hxx>
38 #include <bulmaper.hxx>
39 #include <DrawDocShell.hxx>
41 namespace sd {
43 /**
44 * Constructor of tab dialog: append pages to the dialog
46 OutlineBulletDlg::OutlineBulletDlg(weld::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView)
47 : SfxTabDialogController(pParent, u"modules/sdraw/ui/bulletsandnumbering.ui"_ustr, u"BulletsAndNumberingDialog"_ustr)
48 , m_aInputSet(*pAttr)
49 , m_bTitle(false)
50 , m_pSdView(pView)
52 m_aInputSet.MergeRange(SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL);
53 m_aInputSet.Put(*pAttr);
55 m_xOutputSet.reset( new SfxItemSet( *pAttr ) );
56 m_xOutputSet->ClearItem();
58 bool bOutliner = false;
60 // special treatment if a title object is selected
61 if (pView)
63 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
64 const size_t nCount = rMarkList.GetMarkCount();
65 for(size_t nNum = 0; nNum < nCount; ++nNum)
67 SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
68 if( pObj->GetObjInventor() == SdrInventor::Default )
70 switch(pObj->GetObjIdentifier())
72 case SdrObjKind::TitleText:
73 m_bTitle = true;
74 break;
75 case SdrObjKind::OutlineText:
76 bOutliner = true;
77 break;
78 default:
79 break;
85 if( SfxItemState::SET != m_aInputSet.GetItemState(EE_PARA_NUMBULLET))
87 const SvxNumBulletItem *pItem = nullptr;
88 if(bOutliner)
90 SfxStyleSheetBasePool* pSSPool = pView->GetDocSh()->GetStyleSheetPool();
91 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( STR_LAYOUT_OUTLINE + " 1", SfxStyleFamily::Pseudo);
92 if( pFirstStyleSheet )
93 pItem = pFirstStyleSheet->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET, false);
96 if( pItem == nullptr )
97 pItem = m_aInputSet.GetPool()->GetSecondaryPool()->GetUserDefaultItem(EE_PARA_NUMBULLET);
99 assert(pItem && "No EE_PARA_NUMBULLET in Pool! [CL]");
101 m_aInputSet.Put(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
104 const SvxNumBulletItem* pBulletItem = nullptr;
105 if (m_bTitle && m_aInputSet.GetItemState(EE_PARA_NUMBULLET, true, &pBulletItem) == SfxItemState::SET )
107 const SvxNumRule& rRule = pBulletItem->GetNumRule();
108 SvxNumRule aNewRule( rRule );
109 aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS );
111 SvxNumBulletItem aNewItem( std::move(aNewRule), EE_PARA_NUMBULLET );
112 m_aInputSet.Put(aNewItem);
115 SetInputSet(&m_aInputSet);
117 if (m_bTitle)
118 RemoveTabPage(u"singlenum"_ustr);
120 AddTabPage(u"customize"_ustr, RID_SVXPAGE_NUM_OPTIONS);
121 AddTabPage(u"position"_ustr, RID_SVXPAGE_NUM_POSITION);
124 OutlineBulletDlg::~OutlineBulletDlg()
128 void OutlineBulletDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
130 if (!m_pSdView)
131 return;
132 if (rId == "customize")
134 FieldUnit eMetric = m_pSdView->GetDoc().GetUIUnit();
135 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
136 aSet.Put ( SfxUInt16Item(SID_METRIC_ITEM,static_cast<sal_uInt16>(eMetric)));
137 rPage.PageCreated(aSet);
139 else if (rId == "position")
141 FieldUnit eMetric = m_pSdView->GetDoc().GetUIUnit();
142 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
143 aSet.Put ( SfxUInt16Item(SID_METRIC_ITEM,static_cast<sal_uInt16>(eMetric)));
144 rPage.PageCreated(aSet);
148 const SfxItemSet* OutlineBulletDlg::GetBulletOutputItemSet() const
150 SfxItemSet aSet(*GetOutputItemSet());
151 m_xOutputSet->Put(aSet);
153 const SfxPoolItem *pItem = nullptr;
154 if( SfxItemState::SET == m_xOutputSet->GetItemState(m_xOutputSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE), false, &pItem ))
156 SdBulletMapper::MapFontsInNumRule(const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()), *m_xOutputSet);
157 // #i35937 - removed EE_PARA_BULLETSTATE setting
160 const SvxNumBulletItem* pBulletItem = nullptr;
161 if (m_bTitle && m_xOutputSet->GetItemState(EE_PARA_NUMBULLET, true, &pBulletItem) == SfxItemState::SET)
163 SvxNumRule& rRule = const_cast<SvxNumRule&>(pBulletItem->GetNumRule());
164 rRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS, false );
167 return m_xOutputSet.get();
170 } // end of namespace sd
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */