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 .
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>
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>
40 #define IS_OUTLINE(x) (x >= PresentationObjects::Outline_1 && x <= PresentationObjects::Outline_9)
43 * Constructor of Tab dialog: appends pages to the dialog
45 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg(SfxObjectShell
const * pDocSh
,
46 weld::Window
* pParent
,
48 SfxStyleSheetBase
& rStyleBase
,
49 PresentationObjects _ePO
,
50 SfxStyleSheetBasePool
* pSSPool
)
51 : SfxTabDialogController(pParent
, u
"modules/sdraw/ui/drawprtldialog.ui"_ustr
, u
"DrawPRTLDialog"_ustr
)
54 , aInputSet(*rStyleBase
.GetItemSet().GetPool(), svl::Items
<SID_PARAM_NUM_PRESET
, SID_PARAM_CUR_NUM_LEVEL
>)
56 const SfxItemSet
* pOrgSet(&rStyleBase
.GetItemSet());
60 // Unfortunately, the Itemsets of our style sheets are not discrete...
61 const WhichRangesContainer
& pPtr
= pOrgSet
->GetRanges();
63 for( sal_Int32 i
= 0; i
< pPtr
.size(); ++i
)
68 // first, we make it discrete
69 while(i
< pPtr
.size() - 1 && (pPtr
[i
+1].first
- p2
== 1))
71 p2
= pPtr
[i
+1].second
;
74 aInputSet
.MergeRange( p1
, p2
);
77 aInputSet
.Put( rStyleBase
.GetItemSet() );
79 // need parent-relationship
80 const SfxItemSet
* pParentItemSet
= rStyleBase
.GetItemSet().GetParent();
82 aInputSet
.SetParent( pParentItemSet
);
84 pOutSet
.reset( new SfxItemSet( rStyleBase
.GetItemSet() ) );
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
))
92 OUString
aStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE
) + " 1");
93 SfxStyleSheetBase
* pFirstStyleSheet
= pSSPool
->Find( aStyleName
, SfxStyleFamily::Pseudo
);
96 if( SfxItemState::SET
== pFirstStyleSheet
->GetItemSet().GetItemState(EE_PARA_NUMBULLET
, false, &pItem
) )
97 aInputSet
.Put( *pItem
);
100 // preselect selected layer in dialog
101 aInputSet
.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL
, 1<<GetOutlineLevel()));
103 SetInputSet(&aInputSet
);
106 SetInputSet(pOrgSet
);
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
);
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();
125 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
127 AddTabPage( u
"RID_SVXPAGE_LINE"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_LINE
), nullptr );
128 AddTabPage( u
"RID_SVXPAGE_AREA"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_AREA
), nullptr );
129 AddTabPage( u
"RID_SVXPAGE_SHADOW"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_SHADOW
), nullptr );
130 AddTabPage( u
"RID_SVXPAGE_TRANSPARENCE"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE
), nullptr );
131 AddTabPage( u
"RID_SVXPAGE_CHAR_NAME"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME
), nullptr );
132 AddTabPage( u
"RID_SVXPAGE_CHAR_EFFECTS"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS
), nullptr );
133 AddTabPage( u
"RID_SVXPAGE_STD_PARAGRAPH"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_STD_PARAGRAPH
), nullptr );
134 AddTabPage( u
"RID_SVXPAGE_TEXTATTR"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_TEXTATTR
), nullptr );
135 AddTabPage( u
"RID_SVXPAGE_PICK_BULLET"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BULLET
), nullptr );
136 AddTabPage( u
"RID_SVXPAGE_PICK_SINGLE_NUM"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_SINGLE_NUM
), nullptr );
137 AddTabPage( u
"RID_SVXPAGE_PICK_BMP"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BMP
), nullptr );
138 AddTabPage( u
"RID_SVXPAGE_NUM_OPTIONS"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_NUM_OPTIONS
), nullptr );
139 AddTabPage( u
"RID_SVXPAGE_TABULATOR"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_TABULATOR
), nullptr );
140 AddTabPage( u
"RID_SVXPAGE_PARA_ASIAN"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PARA_ASIAN
), nullptr );
141 AddTabPage( u
"RID_SVXPAGE_ALIGN_PARAGRAPH"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGN_PARAGRAPH
), nullptr );
142 AddTabPage( u
"RID_SVXPAGE_BKG"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BKG
), nullptr);
144 if (!SvtCJKOptions::IsAsianTypographyEnabled() || bBackground
)
145 RemoveTabPage( u
"RID_SVXPAGE_PARA_ASIAN"_ustr
);
149 RemoveTabPage( u
"RID_SVXPAGE_LINE"_ustr
);
151 RemoveTabPage( u
"RID_SVXPAGE_SHADOW"_ustr
);
152 RemoveTabPage( u
"RID_SVXPAGE_TRANSPARENCE"_ustr
);
153 RemoveTabPage( u
"RID_SVXPAGE_CHAR_NAME"_ustr
);
154 RemoveTabPage( u
"RID_SVXPAGE_CHAR_EFFECTS"_ustr
);
155 RemoveTabPage( u
"RID_SVXPAGE_STD_PARAGRAPH"_ustr
);
156 RemoveTabPage( u
"RID_SVXPAGE_TEXTATTR"_ustr
);
157 RemoveTabPage( u
"RID_SVXPAGE_PICK_BULLET"_ustr
);
158 RemoveTabPage( u
"RID_SVXPAGE_PICK_SINGLE_NUM"_ustr
);
159 RemoveTabPage( u
"RID_SVXPAGE_PICK_BMP"_ustr
);
160 RemoveTabPage( u
"RID_SVXPAGE_NUM_OPTIONS"_ustr
);
161 RemoveTabPage( u
"RID_SVXPAGE_TABULATOR"_ustr
);
162 RemoveTabPage( u
"RID_SVXPAGE_ALIGN_PARAGRAPH"_ustr
);
163 RemoveTabPage( u
"RID_SVXPAGE_BKG"_ustr
);
166 // set title and add corresponding pages to dialog
171 case PresentationObjects::Title
:
172 aTitle
= SdResId(STR_PSEUDOSHEET_TITLE
);
175 case PresentationObjects::Subtitle
:
176 aTitle
= SdResId(STR_PSEUDOSHEET_SUBTITLE
);
179 case PresentationObjects::Background
:
180 aTitle
= SdResId(STR_PSEUDOSHEET_BACKGROUND
);
183 case PresentationObjects::BackgroundObjects
:
184 aTitle
= SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS
);
187 case PresentationObjects::Outline_1
:
188 case PresentationObjects::Outline_2
:
189 case PresentationObjects::Outline_3
:
190 case PresentationObjects::Outline_4
:
191 case PresentationObjects::Outline_5
:
192 case PresentationObjects::Outline_6
:
193 case PresentationObjects::Outline_7
:
194 case PresentationObjects::Outline_8
:
195 case PresentationObjects::Outline_9
:
196 aTitle
= SdResId(STR_PSEUDOSHEET_OUTLINE
) + " " +
197 OUString::number( static_cast<int>(ePO
) - static_cast<int>(PresentationObjects::Outline_1
) + 1 );
200 case PresentationObjects::Notes
:
201 aTitle
= SdResId(STR_PSEUDOSHEET_NOTES
);
204 m_xDialog
->set_title(aTitle
);
207 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
211 void SdPresLayoutTemplateDlg::PageCreated(const OUString
& rId
, SfxTabPage
&rPage
)
213 SfxAllItemSet
aSet(*(aInputSet
.GetPool()));
215 if (rId
== "RID_SVXPAGE_LINE")
217 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
218 aSet
.Put (SvxDashListItem(pDashList
,SID_DASH_LIST
));
219 aSet
.Put (SvxLineEndListItem(pLineEndList
,SID_LINEEND_LIST
));
220 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
221 rPage
.PageCreated(aSet
);
223 else if (rId
== "RID_SVXPAGE_AREA")
225 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
226 aSet
.Put (SvxGradientListItem(pGradientList
,SID_GRADIENT_LIST
));
227 aSet
.Put (SvxHatchListItem(pHatchingList
,SID_HATCH_LIST
));
228 aSet
.Put (SvxBitmapListItem(pBitmapList
,SID_BITMAP_LIST
));
229 aSet
.Put (SvxPatternListItem(pPatternList
,SID_PATTERN_LIST
));
230 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
231 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
232 aSet
.Put (SfxUInt16Item(SID_TABPAGE_POS
,0));
233 rPage
.PageCreated(aSet
);
235 else if (rId
== "RID_SVXPAGE_SHADOW")
237 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
238 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
239 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
240 rPage
.PageCreated(aSet
);
242 else if (rId
== "RID_SVXPAGE_TRANSPARENCE")
244 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
245 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
246 rPage
.PageCreated(aSet
);
248 else if (rId
== "RID_SVXPAGE_CHAR_NAME")
250 SvxFontListItem
aItem(*static_cast<const SvxFontListItem
*>(mpDocShell
->GetItem( SID_ATTR_CHAR_FONTLIST
) ) );
251 aSet
.Put (SvxFontListItem( aItem
.GetFontList(), SID_ATTR_CHAR_FONTLIST
));
252 rPage
.PageCreated(aSet
);
254 else if (rId
== "RID_SVXPAGE_CHAR_EFFECTS")
256 rPage
.PageCreated(aSet
);
258 else if (rId
== "RID_SVXPAGE_TEXTATTR")
260 aSet
.Put(CntUInt16Item(SID_SVXTEXTATTRPAGE_OBJKIND
, static_cast<sal_uInt16
>(SdrObjKind::Text
)));
261 rPage
.PageCreated(aSet
);
263 else if (rId
== "RID_SVXPAGE_BKG")
265 aSet
.Put(SfxUInt32Item(SID_FLAG_TYPE
,static_cast<sal_uInt32
>(SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR
)));
266 rPage
.PageCreated(aSet
);
270 const SfxItemSet
* SdPresLayoutTemplateDlg::GetOutputItemSet() const
274 pOutSet
->Put(*SfxTabDialogController::GetOutputItemSet());
276 const SvxNumBulletItem
*pSvxNumBulletItem
= pOutSet
->GetItemIfSet(EE_PARA_NUMBULLET
, false);
277 if (pSvxNumBulletItem
)
278 SdBulletMapper::MapFontsInNumRule( const_cast<SvxNumRule
&>(pSvxNumBulletItem
->GetNumRule()), *pOutSet
);
279 return pOutSet
.get();
282 return SfxTabDialogController::GetOutputItemSet();
285 sal_uInt16
SdPresLayoutTemplateDlg::GetOutlineLevel() const
289 case PresentationObjects::Outline_1
: return 0;
290 case PresentationObjects::Outline_2
: return 1;
291 case PresentationObjects::Outline_3
: return 2;
292 case PresentationObjects::Outline_4
: return 3;
293 case PresentationObjects::Outline_5
: return 4;
294 case PresentationObjects::Outline_6
: return 5;
295 case PresentationObjects::Outline_7
: return 6;
296 case PresentationObjects::Outline_8
: return 7;
297 case PresentationObjects::Outline_9
: return 8;
299 SAL_WARN( "sd", "Wrong Po! [CL]");
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */