bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / dlg / dlgolbul.cxx
blobf62057f8ce4194bd0509d89777de79281cf00c01
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 <drawdoc.hxx>
36 #include <strings.hxx>
37 #include <bulmaper.hxx>
38 #include <DrawDocShell.hxx>
39 #include <svl/aeitem.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, "modules/sdraw/ui/bulletsandnumbering.ui", "BulletsAndNumberingDialog")
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 )
71 switch(pObj->GetObjIdentifier())
73 case OBJ_TITLETEXT:
74 m_bTitle = true;
75 break;
76 case OBJ_OUTLINETEXT:
77 bOutliner = true;
78 break;
84 if( SfxItemState::SET != m_aInputSet.GetItemState(EE_PARA_NUMBULLET))
86 const SvxNumBulletItem *pItem = nullptr;
87 if(bOutliner)
89 SfxStyleSheetBasePool* pSSPool = pView->GetDocSh()->GetStyleSheetPool();
90 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( STR_LAYOUT_OUTLINE " 1", SfxStyleFamily::Pseudo);
91 if( pFirstStyleSheet )
92 pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, false, reinterpret_cast<const SfxPoolItem**>(&pItem));
95 if( pItem == nullptr )
96 pItem = m_aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
98 DBG_ASSERT( pItem, "No EE_PARA_NUMBULLET in Pool! [CL]" );
100 m_aInputSet.Put(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
103 if (m_bTitle && m_aInputSet.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET )
105 const SvxNumBulletItem* pItem = m_aInputSet.GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET);
106 SvxNumRule* pRule = pItem->GetNumRule();
107 if(pRule)
109 SvxNumRule aNewRule( *pRule );
110 aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS );
112 SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET );
113 m_aInputSet.Put(aNewItem);
117 SetInputSet(&m_aInputSet);
119 if (m_bTitle)
120 RemoveTabPage("singlenum");
122 AddTabPage("customize", RID_SVXPAGE_NUM_OPTIONS);
123 AddTabPage("position", RID_SVXPAGE_NUM_POSITION);
126 OutlineBulletDlg::~OutlineBulletDlg()
130 void OutlineBulletDlg::PageCreated(const OString& rId, SfxTabPage &rPage)
132 if (!m_pSdView)
133 return;
134 if (rId == "customize")
136 FieldUnit eMetric = m_pSdView->GetDoc().GetUIUnit();
137 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
138 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,static_cast<sal_uInt16>(eMetric)));
139 rPage.PageCreated(aSet);
141 else if (rId == "position")
143 FieldUnit eMetric = m_pSdView->GetDoc().GetUIUnit();
144 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
145 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,static_cast<sal_uInt16>(eMetric)));
146 rPage.PageCreated(aSet);
150 const SfxItemSet* OutlineBulletDlg::GetBulletOutputItemSet() const
152 SfxItemSet aSet(*GetOutputItemSet());
153 m_xOutputSet->Put(aSet);
155 const SfxPoolItem *pItem = nullptr;
156 if( SfxItemState::SET == m_xOutputSet->GetItemState(m_xOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), false, &pItem ))
158 SdBulletMapper::MapFontsInNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule(), *m_xOutputSet);
159 // #i35937 - removed EE_PARA_BULLETSTATE setting
162 if (m_bTitle && m_xOutputSet->GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET)
164 const SvxNumBulletItem* pBulletItem = m_xOutputSet->GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET);
165 SvxNumRule* pRule = pBulletItem->GetNumRule();
166 if(pRule)
167 pRule->SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS, false );
170 return m_xOutputSet.get();
173 } // end of namespace sd
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */