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/svdobj.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 >= PO_OUTLINE_1 && x <= PO_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
, "modules/sdraw/ui/drawprtldialog.ui", "DrawPRTLDialog")
54 , aInputSet(*rStyleBase
.GetItemSet().GetPool(), svl::Items
<SID_PARAM_NUM_PRESET
, SID_PARAM_CUR_NUM_LEVEL
>{})
55 , pOrgSet(&rStyleBase
.GetItemSet())
59 // Unfortunately, the Itemsets of our style sheets are not discreet..
60 const sal_uInt16
* pPtr
= pOrgSet
->GetRanges();
67 // first, we make it discreet
68 while(pPtr
[2] && (pPtr
[2] - p2
== 1))
73 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( "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_BACKGROUND", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BKG
), nullptr);
144 SvtCJKOptions aCJKOptions
;
145 if( !aCJKOptions
.IsAsianTypographyEnabled() )
146 RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
150 RemoveTabPage( "RID_SVXPAGE_LINE");
152 RemoveTabPage( "RID_SVXPAGE_SHADOW");
153 RemoveTabPage( "RID_SVXPAGE_TRANSPARENCE");
154 RemoveTabPage( "RID_SVXPAGE_CHAR_NAME");
155 RemoveTabPage( "RID_SVXPAGE_CHAR_EFFECTS");
156 RemoveTabPage( "RID_SVXPAGE_STD_PARAGRAPH");
157 RemoveTabPage( "RID_SVXPAGE_TEXTATTR");
158 RemoveTabPage( "RID_SVXPAGE_PICK_BULLET");
159 RemoveTabPage( "RID_SVXPAGE_PICK_SINGLE_NUM");
160 RemoveTabPage( "RID_SVXPAGE_PICK_BMP");
161 RemoveTabPage( "RID_SVXPAGE_NUM_OPTIONS");
162 RemoveTabPage( "RID_SVXPAGE_TABULATOR");
163 RemoveTabPage( "RID_SVXPAGE_ALIGN_PARAGRAPH");
164 RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
165 RemoveTabPage( "RID_SVXPAGE_BACKGROUND" );
168 // set title and add corresponding pages to dialog
174 aTitle
= SdResId(STR_PSEUDOSHEET_TITLE
);
178 aTitle
= SdResId(STR_PSEUDOSHEET_SUBTITLE
);
182 aTitle
= SdResId(STR_PSEUDOSHEET_BACKGROUND
);
185 case PO_BACKGROUNDOBJECTS
:
186 aTitle
= SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS
);
198 aTitle
= SdResId(STR_PSEUDOSHEET_OUTLINE
) + " " +
199 OUString::number( ePO
- PO_OUTLINE_1
+ 1 );
203 aTitle
= SdResId(STR_PSEUDOSHEET_NOTES
);
206 m_xDialog
->set_title(aTitle
);
209 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
213 void SdPresLayoutTemplateDlg::PageCreated(const OString
& rId
, SfxTabPage
&rPage
)
215 SfxAllItemSet
aSet(*(aInputSet
.GetPool()));
217 if (rId
== "RID_SVXPAGE_LINE")
219 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
220 aSet
.Put (SvxDashListItem(pDashList
,SID_DASH_LIST
));
221 aSet
.Put (SvxLineEndListItem(pLineEndList
,SID_LINEEND_LIST
));
222 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
223 rPage
.PageCreated(aSet
);
225 else if (rId
== "RID_SVXPAGE_AREA")
227 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
228 aSet
.Put (SvxGradientListItem(pGradientList
,SID_GRADIENT_LIST
));
229 aSet
.Put (SvxHatchListItem(pHatchingList
,SID_HATCH_LIST
));
230 aSet
.Put (SvxBitmapListItem(pBitmapList
,SID_BITMAP_LIST
));
231 aSet
.Put (SvxPatternListItem(pPatternList
,SID_PATTERN_LIST
));
232 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
233 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
234 aSet
.Put (SfxUInt16Item(SID_TABPAGE_POS
,0));
235 rPage
.PageCreated(aSet
);
237 else if (rId
== "RID_SVXPAGE_SHADOW")
239 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
240 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
241 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
242 rPage
.PageCreated(aSet
);
244 else if (rId
== "RID_SVXPAGE_TRANSPARENCE")
246 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
247 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
248 rPage
.PageCreated(aSet
);
250 else if (rId
== "RID_SVXPAGE_CHAR_NAME")
252 SvxFontListItem
aItem(*static_cast<const SvxFontListItem
*>(mpDocShell
->GetItem( SID_ATTR_CHAR_FONTLIST
) ) );
253 aSet
.Put (SvxFontListItem( aItem
.GetFontList(), SID_ATTR_CHAR_FONTLIST
));
254 rPage
.PageCreated(aSet
);
256 else if (rId
== "RID_SVXPAGE_CHAR_EFFECTS")
258 rPage
.PageCreated(aSet
);
260 else if (rId
== "RID_SVXPAGE_TEXTATTR")
262 aSet
.Put(CntUInt16Item(SID_SVXTEXTATTRPAGE_OBJKIND
, OBJ_TEXT
));
263 rPage
.PageCreated(aSet
);
265 else if (rId
== "RID_SVXPAGE_BACKGROUND")
267 aSet
.Put(SfxUInt32Item(SID_FLAG_TYPE
,static_cast<sal_uInt32
>(SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR
)));
268 rPage
.PageCreated(aSet
);
272 const SfxItemSet
* SdPresLayoutTemplateDlg::GetOutputItemSet() const
276 pOutSet
->Put(*SfxTabDialogController::GetOutputItemSet());
278 const SvxNumBulletItem
*pSvxNumBulletItem
= nullptr;
279 if (SfxItemState::SET
== pOutSet
->GetItemState(EE_PARA_NUMBULLET
, false, reinterpret_cast<const SfxPoolItem
**>(&pSvxNumBulletItem
)))
280 SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem
->GetNumRule(), *pOutSet
);
281 return pOutSet
.get();
284 return SfxTabDialogController::GetOutputItemSet();
287 sal_uInt16
SdPresLayoutTemplateDlg::GetOutlineLevel() const
291 case PO_OUTLINE_1
: return 0;
292 case PO_OUTLINE_2
: return 1;
293 case PO_OUTLINE_3
: return 2;
294 case PO_OUTLINE_4
: return 3;
295 case PO_OUTLINE_5
: return 4;
296 case PO_OUTLINE_6
: return 5;
297 case PO_OUTLINE_7
: return 6;
298 case PO_OUTLINE_8
: return 7;
299 case PO_OUTLINE_9
: return 8;
301 SAL_WARN( "sd", "Wrong Po! [CL]");
306 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */