1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
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>
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
)
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
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
:
75 case SdrObjKind::OutlineText
:
85 if( SfxItemState::SET
!= m_aInputSet
.GetItemState(EE_PARA_NUMBULLET
))
87 const SvxNumBulletItem
*pItem
= nullptr;
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
);
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
)
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: */