LibreOffice Module sd (master) 1
dlgolbul.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#include <OutlineBulletDlg.hxx>
22
23#include <svx/svxids.hrc>
24#include <editeng/eeitem.hxx>
25
26#include <editeng/numitem.hxx>
27
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>
36
37#include <strings.hxx>
38#include <bulmaper.hxx>
39#include <DrawDocShell.hxx>
40
41namespace sd {
42
47 : SfxTabDialogController(pParent, "modules/sdraw/ui/bulletsandnumbering.ui", "BulletsAndNumberingDialog")
48 , m_aInputSet(*pAttr)
49 , m_bTitle(false)
50 , m_pSdView(pView)
51{
52 m_aInputSet.MergeRange(SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL);
53 m_aInputSet.Put(*pAttr);
54
55 m_xOutputSet.reset( new SfxItemSet( *pAttr ) );
56 m_xOutputSet->ClearItem();
57
58 bool bOutliner = false;
59
60 // special treatment if a title object is selected
61 if (pView)
62 {
63 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
64 const size_t nCount = rMarkList.GetMarkCount();
65 for(size_t nNum = 0; nNum < nCount; ++nNum)
66 {
67 SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
68 if( pObj->GetObjInventor() == SdrInventor::Default )
69 {
70 switch(pObj->GetObjIdentifier())
71 {
72 case SdrObjKind::TitleText:
73 m_bTitle = true;
74 break;
75 case SdrObjKind::OutlineText:
76 bOutliner = true;
77 break;
78 default:
79 break;
80 }
81 }
82 }
83 }
84
85 if( SfxItemState::SET != m_aInputSet.GetItemState(EE_PARA_NUMBULLET))
86 {
87 const SvxNumBulletItem *pItem = nullptr;
88 if(bOutliner)
89 {
91 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( STR_LAYOUT_OUTLINE + " 1", SfxStyleFamily::Pseudo);
92 if( pFirstStyleSheet )
93 pItem = pFirstStyleSheet->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET, false);
94 }
95
96 if( pItem == nullptr )
98
99 DBG_ASSERT( pItem, "No EE_PARA_NUMBULLET in Pool! [CL]" );
100
101 m_aInputSet.Put(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
102 }
103
104 if (m_bTitle && m_aInputSet.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET )
105 {
107 const SvxNumRule& rRule = pItem->GetNumRule();
108 SvxNumRule aNewRule( rRule );
109 aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS );
110
111 SvxNumBulletItem aNewItem( std::move(aNewRule), EE_PARA_NUMBULLET );
112 m_aInputSet.Put(aNewItem);
113 }
114
116
117 if (m_bTitle)
118 RemoveTabPage("singlenum");
119
120 AddTabPage("customize", RID_SVXPAGE_NUM_OPTIONS);
121 AddTabPage("position", RID_SVXPAGE_NUM_POSITION);
122}
123
125{
126}
127
128void OutlineBulletDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
129{
130 if (!m_pSdView)
131 return;
132 if (rId == "customize")
133 {
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);
138 }
139 else if (rId == "position")
140 {
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);
145 }
146}
147
149{
151 m_xOutputSet->Put(aSet);
152
153 const SfxPoolItem *pItem = nullptr;
154 if( SfxItemState::SET == m_xOutputSet->GetItemState(m_xOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), false, &pItem ))
155 {
156 SdBulletMapper::MapFontsInNumRule(const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()), *m_xOutputSet);
157 // #i35937 - removed EE_PARA_BULLETSTATE setting
158 }
159
160 if (m_bTitle && m_xOutputSet->GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET)
161 {
162 const SvxNumBulletItem* pBulletItem = m_xOutputSet->GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET);
163 SvxNumRule& rRule = const_cast<SvxNumRule&>(pBulletItem->GetNumRule());
164 rRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS, false );
165 }
166
167 return m_xOutputSet.get();
168}
169
170} // end of namespace sd
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void MapFontsInNumRule(SvxNumRule &aNumRule, const SfxItemSet &rSet)
Definition: bulmaper.cxx:42
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
SdrObject * GetMarkedSdrObj() const
FieldUnit GetUIUnit() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const
SfxItemPool * GetSecondaryPool() const
const SfxPoolItem * GetPoolDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual SfxItemSet & GetItemSet()
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void SetInputSet(const SfxItemSet *pInSet)
void RemoveTabPage(const OUString &rName)
const SfxItemSet * GetOutputItemSet() const
SfxItemSet * GetInputSetImpl()
virtual void PageCreated(const SfxAllItemSet &aSet)
const SvxNumRule & GetNumRule() const
void SetFeatureFlag(SvxNumRuleFlags nFlag, bool bSet=true)
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
Definition: docshel4.cxx:690
OutlineBulletDlg(weld::Window *pParent, const SfxItemSet *pAttr, ::sd::View *pView)
Constructor of tab dialog: append pages to the dialog.
Definition: dlgolbul.cxx:46
virtual ~OutlineBulletDlg() override
Definition: dlgolbul.cxx:124
const SfxItemSet * GetBulletOutputItemSet() const
Definition: dlgolbul.cxx:148
std::unique_ptr< SfxItemSet > m_xOutputSet
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
Definition: dlgolbul.cxx:128
DrawDocShell * GetDocSh() const
Definition: View.hxx:142
SdDrawDocument & GetDoc() const
Definition: View.hxx:293
int nCount
#define DBG_ASSERT(sCon, aError)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
FieldUnit
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
constexpr OUStringLiteral STR_LAYOUT_OUTLINE
Definition: strings.hxx:16