LibreOffice Module sd (master) 1
prltempl.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 <sal/log.hxx>
21#include <svx/dialogs.hrc>
22#include <svx/svxids.hrc>
23#include <editeng/flstitem.hxx>
24#include <svx/drawitem.hxx>
25#include <svl/style.hxx>
26#include <svx/svdobjkind.hxx>
27#include <editeng/eeitem.hxx>
28#include <editeng/numitem.hxx>
29#include <svl/cjkoptions.hxx>
30#include <sfx2/objsh.hxx>
31#include <sfx2/sfxdlg.hxx>
32
33#include <strings.hrc>
34#include <sdresid.hxx>
35#include <prltempl.hxx>
36#include <bulmaper.hxx>
37#include <svl/intitem.hxx>
38#include <svx/flagsdef.hxx>
39
40#define IS_OUTLINE(x) (x >= PresentationObjects::Outline_1 && x <= PresentationObjects::Outline_9)
41
46 weld::Window* pParent,
47 bool bBackground,
48 SfxStyleSheetBase& rStyleBase,
50 SfxStyleSheetBasePool* pSSPool)
51 : SfxTabDialogController(pParent, "modules/sdraw/ui/drawprtldialog.ui", "DrawPRTLDialog")
52 , mpDocShell(pDocSh)
53 , ePO(_ePO)
54 , aInputSet(*rStyleBase.GetItemSet().GetPool(), svl::Items<SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL>)
55{
56 const SfxItemSet* pOrgSet(&rStyleBase.GetItemSet());
57
58 if( IS_OUTLINE(ePO))
59 {
60 // Unfortunately, the Itemsets of our style sheets are not discrete...
61 const WhichRangesContainer& pPtr = pOrgSet->GetRanges();
62 sal_uInt16 p1, p2;
63 for( sal_Int32 i = 0; i < pPtr.size(); ++i )
64 {
65 p1 = pPtr[i].first;
66 p2 = pPtr[i].second;
67
68 // first, we make it discrete
69 while(i < pPtr.size() - 1 && (pPtr[i+1].first - p2 == 1))
70 {
71 p2 = pPtr[i+1].second;
72 ++i;
73 }
74 aInputSet.MergeRange( p1, p2 );
75 }
76
77 aInputSet.Put( rStyleBase.GetItemSet() );
78
79 // need parent-relationship
80 const SfxItemSet* pParentItemSet = rStyleBase.GetItemSet().GetParent();
81 if( pParentItemSet )
82 aInputSet.SetParent( pParentItemSet );
83
84 pOutSet.reset( new SfxItemSet( rStyleBase.GetItemSet() ) );
85 pOutSet->ClearItem();
86
87 // If there is no bullet item in this stylesheet, we get it
88 // from 'Outline 1' style sheet.
89 const SfxPoolItem *pItem = nullptr;
90 if( SfxItemState::SET != aInputSet.GetItemState(EE_PARA_NUMBULLET, false, &pItem ))
91 {
92 OUString aStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1");
93 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SfxStyleFamily::Pseudo);
94
95 if(pFirstStyleSheet)
96 if( SfxItemState::SET == pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, false, &pItem) )
97 aInputSet.Put( *pItem );
98 }
99
100 // preselect selected layer in dialog
101 aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel()));
102
104 }
105 else {
106 SetInputSet(pOrgSet);
107 }
108
109 SvxColorListItem const *pColorListItem = mpDocShell->GetItem( SID_COLOR_TABLE );
110 SvxGradientListItem const *pGradientListItem = mpDocShell->GetItem( SID_GRADIENT_LIST );
111 SvxBitmapListItem const *pBitmapListItem = mpDocShell->GetItem( SID_BITMAP_LIST );
112 SvxPatternListItem const *pPatternListItem = mpDocShell->GetItem( SID_PATTERN_LIST );
113 SvxHatchListItem const *pHatchListItem = mpDocShell->GetItem( SID_HATCH_LIST );
114 SvxDashListItem const *pDashListItem = mpDocShell->GetItem( SID_DASH_LIST );
115 SvxLineEndListItem const *pLineEndListItem = mpDocShell->GetItem( SID_LINEEND_LIST );
116
117 pColorTab = pColorListItem->GetColorList();
118 pDashList = pDashListItem->GetDashList();
119 pLineEndList = pLineEndListItem->GetLineEndList();
120 pGradientList = pGradientListItem->GetGradientList();
121 pHatchingList = pHatchListItem->GetHatchList();
122 pBitmapList = pBitmapListItem->GetBitmapList();
123 pPatternList = pPatternListItem->GetPatternList();
124
126
127 AddTabPage( "RID_SVXPAGE_LINE", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_LINE ), nullptr );
128 AddTabPage( "RID_SVXPAGE_AREA", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), nullptr );
129 AddTabPage( "RID_SVXPAGE_SHADOW", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_SHADOW ), nullptr );
130 AddTabPage( "RID_SVXPAGE_TRANSPARENCE", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), nullptr );
131 AddTabPage( "RID_SVXPAGE_CHAR_NAME", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), nullptr );
132 AddTabPage( "RID_SVXPAGE_CHAR_EFFECTS", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), nullptr );
133 AddTabPage( "RID_SVXPAGE_STD_PARAGRAPH", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_STD_PARAGRAPH ), nullptr );
134 AddTabPage( "RID_SVXPAGE_TEXTATTR", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TEXTATTR ), nullptr );
135 AddTabPage( "RID_SVXPAGE_PICK_BULLET", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BULLET ), nullptr );
136 AddTabPage( "RID_SVXPAGE_PICK_SINGLE_NUM", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_SINGLE_NUM ), nullptr );
137 AddTabPage( "RID_SVXPAGE_PICK_BMP", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BMP ), nullptr );
138 AddTabPage( "RID_SVXPAGE_NUM_OPTIONS", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUM_OPTIONS ), nullptr );
139 AddTabPage( "RID_SVXPAGE_TABULATOR", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TABULATOR ), nullptr );
140 AddTabPage( "RID_SVXPAGE_PARA_ASIAN", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PARA_ASIAN ), nullptr );
141 AddTabPage( "RID_SVXPAGE_ALIGN_PARAGRAPH", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGN_PARAGRAPH ), nullptr );
142 AddTabPage( "RID_SVXPAGE_BKG", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ), nullptr);
143
145 RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
146
147 if (bBackground)
148 {
149 RemoveTabPage( "RID_SVXPAGE_LINE");
150
151 RemoveTabPage( "RID_SVXPAGE_SHADOW");
152 RemoveTabPage( "RID_SVXPAGE_TRANSPARENCE");
153 RemoveTabPage( "RID_SVXPAGE_CHAR_NAME");
154 RemoveTabPage( "RID_SVXPAGE_CHAR_EFFECTS");
155 RemoveTabPage( "RID_SVXPAGE_STD_PARAGRAPH");
156 RemoveTabPage( "RID_SVXPAGE_TEXTATTR");
157 RemoveTabPage( "RID_SVXPAGE_PICK_BULLET");
158 RemoveTabPage( "RID_SVXPAGE_PICK_SINGLE_NUM");
159 RemoveTabPage( "RID_SVXPAGE_PICK_BMP");
160 RemoveTabPage( "RID_SVXPAGE_NUM_OPTIONS");
161 RemoveTabPage( "RID_SVXPAGE_TABULATOR");
162 RemoveTabPage( "RID_SVXPAGE_ALIGN_PARAGRAPH");
163 RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
164 RemoveTabPage( "RID_SVXPAGE_BKG" );
165 }
166
167 // set title and add corresponding pages to dialog
168 OUString aTitle;
169
170 switch( ePO )
171 {
173 aTitle = SdResId(STR_PSEUDOSHEET_TITLE);
174 break;
175
177 aTitle = SdResId(STR_PSEUDOSHEET_SUBTITLE);
178 break;
179
181 aTitle = SdResId(STR_PSEUDOSHEET_BACKGROUND);
182 break;
183
185 aTitle = SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS);
186 break;
187
197 aTitle = SdResId(STR_PSEUDOSHEET_OUTLINE) + " " +
198 OUString::number( static_cast<int>(ePO) - static_cast<int>(PresentationObjects::Outline_1) + 1 );
199 break;
200
202 aTitle = SdResId(STR_PSEUDOSHEET_NOTES);
203 break;
204 }
205 m_xDialog->set_title(aTitle);
206}
207
209{
210}
211
212void SdPresLayoutTemplateDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
213{
215
216 if (rId == "RID_SVXPAGE_LINE")
217 {
218 aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
219 aSet.Put (SvxDashListItem(pDashList,SID_DASH_LIST));
220 aSet.Put (SvxLineEndListItem(pLineEndList,SID_LINEEND_LIST));
221 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,1));
222 rPage.PageCreated(aSet);
223 }
224 else if (rId == "RID_SVXPAGE_AREA")
225 {
226 aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
227 aSet.Put (SvxGradientListItem(pGradientList,SID_GRADIENT_LIST));
228 aSet.Put (SvxHatchListItem(pHatchingList,SID_HATCH_LIST));
229 aSet.Put (SvxBitmapListItem(pBitmapList,SID_BITMAP_LIST));
230 aSet.Put (SvxPatternListItem(pPatternList,SID_PATTERN_LIST));
231 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,0));
232 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,1));
233 aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,0));
234 rPage.PageCreated(aSet);
235 }
236 else if (rId == "RID_SVXPAGE_SHADOW")
237 {
238 aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
239 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,0));
240 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,1));
241 rPage.PageCreated(aSet);
242 }
243 else if (rId == "RID_SVXPAGE_TRANSPARENCE")
244 {
245 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,0));
246 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,1));
247 rPage.PageCreated(aSet);
248 }
249 else if (rId == "RID_SVXPAGE_CHAR_NAME")
250 {
251 SvxFontListItem aItem(*static_cast<const SvxFontListItem*>(mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) );
252 aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
253 rPage.PageCreated(aSet);
254 }
255 else if (rId == "RID_SVXPAGE_CHAR_EFFECTS")
256 {
257 rPage.PageCreated(aSet);
258 }
259 else if (rId == "RID_SVXPAGE_TEXTATTR")
260 {
261 aSet.Put(CntUInt16Item(SID_SVXTEXTATTRPAGE_OBJKIND, static_cast<sal_uInt16>(SdrObjKind::Text)));
262 rPage.PageCreated(aSet);
263 }
264 else if (rId == "RID_SVXPAGE_BKG")
265 {
266 aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR)));
267 rPage.PageCreated(aSet);
268 }
269}
270
272{
273 if (pOutSet)
274 {
276
277 const SvxNumBulletItem *pSvxNumBulletItem = pOutSet->GetItemIfSet(EE_PARA_NUMBULLET, false);
278 if (pSvxNumBulletItem)
279 SdBulletMapper::MapFontsInNumRule( const_cast<SvxNumRule&>(pSvxNumBulletItem->GetNumRule()), *pOutSet );
280 return pOutSet.get();
281 }
282 else
284}
285
287{
288 switch( ePO )
289 {
290 case PresentationObjects::Outline_1: return 0;
291 case PresentationObjects::Outline_2: return 1;
292 case PresentationObjects::Outline_3: return 2;
293 case PresentationObjects::Outline_4: return 3;
294 case PresentationObjects::Outline_5: return 4;
295 case PresentationObjects::Outline_6: return 5;
296 case PresentationObjects::Outline_7: return 6;
297 case PresentationObjects::Outline_8: return 7;
298 case PresentationObjects::Outline_9: return 8;
299 default:
300 SAL_WARN( "sd", "Wrong Po! [CL]");
301 }
302 return 0;
303}
304
305/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
static void MapFontsInNumRule(SvxNumRule &aNumRule, const SfxItemSet &rSet)
Definition: bulmaper.cxx:42
SdPresLayoutTemplateDlg(SfxObjectShell const *pDocSh, weld::Window *pParent, bool bBackground, SfxStyleSheetBase &rStyleBase, PresentationObjects ePO, SfxStyleSheetBasePool *pSSPool)
Constructor of Tab dialog: appends pages to the dialog.
Definition: prltempl.cxx:45
std::unique_ptr< SfxItemSet > pOutSet
Definition: prltempl.hxx:53
XLineEndListRef pLineEndList
Definition: prltempl.hxx:45
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
Definition: prltempl.cxx:212
const SfxObjectShell * mpDocShell
Definition: prltempl.hxx:37
XGradientListRef pGradientList
Definition: prltempl.hxx:40
sal_uInt16 GetOutlineLevel() const
Definition: prltempl.cxx:286
virtual ~SdPresLayoutTemplateDlg() override
Definition: prltempl.cxx:208
XDashListRef pDashList
Definition: prltempl.hxx:44
XColorListRef pColorTab
Definition: prltempl.hxx:39
PresentationObjects ePO
Definition: prltempl.hxx:47
XHatchListRef pHatchingList
Definition: prltempl.hxx:41
const SfxItemSet * GetOutputItemSet() const
Definition: prltempl.cxx:271
XPatternListRef pPatternList
Definition: prltempl.hxx:43
XBitmapListRef pBitmapList
Definition: prltempl.hxx:42
static SfxAbstractDialogFactory * Create()
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
const WhichRangesContainer & GetRanges() const
SfxItemPool * GetPool() const
void SetParent(const SfxItemSet *pNew)
const SfxItemSet * GetParent() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
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
virtual void PageCreated(const SfxAllItemSet &aSet)
const XBitmapListRef & GetBitmapList() const
const XColorListRef & GetColorList() const
const XDashListRef & GetDashList() const
const FontList * GetFontList() const
const XGradientListRef & GetGradientList() const
const XHatchListRef & GetHatchList() const
const XLineEndListRef & GetLineEndList() const
const SvxNumRule & GetNumRule() const
const XPatternListRef & GetPatternList() const
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
#define SAL_WARN(area, stream)
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
bool IsAsianTypographyEnabled()
int i
PresentationObjects
Definition: prlayout.hxx:29
#define IS_OUTLINE(x)
Definition: prltempl.cxx:40
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
sal_Int32 size() const noexcept