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 <editeng/outliner.hxx>
22 #include <svx/dialogs.hrc>
23 #include <svx/svxdlg.hxx>
24 #include <editeng/flstitem.hxx>
25 #include <svx/drawitem.hxx>
26 #include <svl/style.hxx>
27 #include <svx/tabline.hxx>
28 #include <editeng/bulletitem.hxx>
29 #include <editeng/eeitem.hxx>
30 #include <editeng/brushitem.hxx>
31 #include <vcl/graph.hxx>
32 #include <editeng/lrspitem.hxx>
33 #include <editeng/numitem.hxx>
34 #include <editeng/colritem.hxx>
35 #include <svl/cjkoptions.hxx>
37 #include <DrawDocShell.hxx>
38 #include <strings.hrc>
39 #include <sdresid.hxx>
40 #include <prltempl.hxx>
41 #include <bulmaper.hxx>
42 #include <svl/intitem.hxx>
43 #include <svx/svxgrahicitem.hxx>
44 #include <svx/flagsdef.hxx>
45 #include <drawdoc.hxx>
46 #define IS_OUTLINE(x) (x >= PO_OUTLINE_1 && x <= PO_OUTLINE_9)
49 * Constructor of Tab dialog: appends pages to the dialog
51 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell
const * pDocSh
,
54 SfxStyleSheetBase
& rStyleBase
,
55 PresentationObjects _ePO
,
56 SfxStyleSheetBasePool
* pSSPool
) :
57 SfxTabDialog ( pParent
59 , "modules/sdraw/ui/drawprtldialog.ui"),
60 mpDocShell ( pDocSh
),
62 aInputSet ( *rStyleBase
.GetItemSet().GetPool(), svl::Items
<SID_PARAM_NUM_PRESET
, SID_PARAM_CUR_NUM_LEVEL
>{} ),
64 pOrgSet ( &rStyleBase
.GetItemSet() )
68 // Unfortunately, the Itemsets of our style sheets are not discreet..
69 const sal_uInt16
* pPtr
= pOrgSet
->GetRanges();
76 // first, we make it discreet
77 while(pPtr
[2] && (pPtr
[2] - p2
== 1))
82 aInputSet
.MergeRange( p1
, p2
);
86 aInputSet
.Put( rStyleBase
.GetItemSet() );
88 // need parent-relationship
89 const SfxItemSet
* pParentItemSet
= rStyleBase
.GetItemSet().GetParent();
91 aInputSet
.SetParent( pParentItemSet
);
93 pOutSet
= new SfxItemSet( rStyleBase
.GetItemSet() );
96 // If there is no bullet item in this stylesheet, we get it
97 // from 'Outline 1' style sheet.
98 const SfxPoolItem
*pItem
= nullptr;
99 if( SfxItemState::SET
!= aInputSet
.GetItemState(EE_PARA_NUMBULLET
, false, &pItem
))
101 OUString
aStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE
) + " 1");
102 SfxStyleSheetBase
* pFirstStyleSheet
= pSSPool
->Find( aStyleName
, SfxStyleFamily::Pseudo
);
105 if( SfxItemState::SET
== pFirstStyleSheet
->GetItemSet().GetItemState(EE_PARA_NUMBULLET
, false, &pItem
) )
106 aInputSet
.Put( *pItem
);
109 // preselect selected layer in dialog
110 aInputSet
.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL
, 1<<GetOutlineLevel()));
112 SetInputSet(&aInputSet
);
115 SetInputSet(pOrgSet
);
118 SvxColorListItem
const *pColorListItem
= mpDocShell
->GetItem( SID_COLOR_TABLE
);
119 SvxGradientListItem
const *pGradientListItem
= mpDocShell
->GetItem( SID_GRADIENT_LIST
);
120 SvxBitmapListItem
const *pBitmapListItem
= mpDocShell
->GetItem( SID_BITMAP_LIST
);
121 SvxPatternListItem
const *pPatternListItem
= mpDocShell
->GetItem( SID_PATTERN_LIST
);
122 SvxHatchListItem
const *pHatchListItem
= mpDocShell
->GetItem( SID_HATCH_LIST
);
123 SvxDashListItem
const *pDashListItem
= mpDocShell
->GetItem( SID_DASH_LIST
);
124 SvxLineEndListItem
const *pLineEndListItem
= mpDocShell
->GetItem( SID_LINEEND_LIST
);
126 pColorTab
= pColorListItem
->GetColorList();
127 pDashList
= pDashListItem
->GetDashList();
128 pLineEndList
= pLineEndListItem
->GetLineEndList();
129 pGradientList
= pGradientListItem
->GetGradientList();
130 pHatchingList
= pHatchListItem
->GetHatchList();
131 pBitmapList
= pBitmapListItem
->GetBitmapList();
132 pPatternList
= pPatternListItem
->GetPatternList();
134 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
135 OSL_ENSURE(pFact
, "Dialog creation failed!");
137 mnLine
= AddTabPage( "RID_SVXPAGE_LINE", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_LINE
), nullptr );
138 mnArea
= AddTabPage( "RID_SVXPAGE_AREA", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_AREA
), nullptr );
139 mnShadow
= AddTabPage( "RID_SVXPAGE_SHADOW", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_SHADOW
), nullptr );
140 mnTransparency
= AddTabPage( "RID_SVXPAGE_TRANSPARENCE", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE
), nullptr );
141 mnFont
= AddTabPage( "RID_SVXPAGE_CHAR_NAME", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME
), nullptr );
142 mnEffects
= AddTabPage( "RID_SVXPAGE_CHAR_EFFECTS", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS
), nullptr );
143 AddTabPage( "RID_SVXPAGE_STD_PARAGRAPH", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_STD_PARAGRAPH
), nullptr );
144 mnTextAtt
= AddTabPage( "RID_SVXPAGE_TEXTATTR", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_TEXTATTR
), nullptr );
145 AddTabPage( "RID_SVXPAGE_PICK_BULLET", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BULLET
), nullptr );
146 AddTabPage( "RID_SVXPAGE_PICK_SINGLE_NUM", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_SINGLE_NUM
), nullptr );
147 AddTabPage( "RID_SVXPAGE_PICK_BMP", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BMP
), nullptr );
148 AddTabPage( "RID_SVXPAGE_NUM_OPTIONS", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_NUM_OPTIONS
), nullptr );
149 AddTabPage( "RID_SVXPAGE_TABULATOR", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_TABULATOR
), nullptr );
150 AddTabPage( "RID_SVXPAGE_PARA_ASIAN", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PARA_ASIAN
), nullptr );
151 AddTabPage( "RID_SVXPAGE_ALIGN_PARAGRAPH", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGN_PARAGRAPH
), nullptr );
152 mnBackground
= AddTabPage( "RID_SVXPAGE_BACKGROUND", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), nullptr);
154 SvtCJKOptions aCJKOptions
;
155 if( !aCJKOptions
.IsAsianTypographyEnabled() )
156 RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
160 RemoveTabPage( "RID_SVXPAGE_LINE");
162 RemoveTabPage( "RID_SVXPAGE_SHADOW");
163 RemoveTabPage( "RID_SVXPAGE_TRANSPARENCE");
164 RemoveTabPage( "RID_SVXPAGE_CHAR_NAME");
165 RemoveTabPage( "RID_SVXPAGE_CHAR_EFFECTS");
166 RemoveTabPage( "RID_SVXPAGE_STD_PARAGRAPH");
167 RemoveTabPage( "RID_SVXPAGE_TEXTATTR");
168 RemoveTabPage( "RID_SVXPAGE_PICK_BULLET");
169 RemoveTabPage( "RID_SVXPAGE_PICK_SINGLE_NUM");
170 RemoveTabPage( "RID_SVXPAGE_PICK_BMP");
171 RemoveTabPage( "RID_SVXPAGE_NUM_OPTIONS");
172 RemoveTabPage( "RID_SVXPAGE_TABULATOR");
173 RemoveTabPage( "RID_SVXPAGE_ALIGN_PARAGRAPH");
174 RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
175 RemoveTabPage( "RID_SVXPAGE_BACKGROUND" );
178 // set title and add corresponding pages to dialog
184 aTitle
= SdResId(STR_PSEUDOSHEET_TITLE
);
188 aTitle
= SdResId(STR_PSEUDOSHEET_SUBTITLE
);
192 aTitle
= SdResId(STR_PSEUDOSHEET_BACKGROUND
);
195 case PO_BACKGROUNDOBJECTS
:
196 aTitle
= SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS
);
208 aTitle
= SdResId(STR_PSEUDOSHEET_OUTLINE
) + " " +
209 OUString::number( ePO
- PO_OUTLINE_1
+ 1 );
213 aTitle
= SdResId(STR_PSEUDOSHEET_NOTES
);
219 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
224 void SdPresLayoutTemplateDlg::dispose()
227 SfxTabDialog::dispose();
230 void SdPresLayoutTemplateDlg::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
232 SfxAllItemSet
aSet(*(aInputSet
.GetPool()));
236 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
237 aSet
.Put (SvxDashListItem(pDashList
,SID_DASH_LIST
));
238 aSet
.Put (SvxLineEndListItem(pLineEndList
,SID_LINEEND_LIST
));
239 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
240 rPage
.PageCreated(aSet
);
242 else if (nId
== mnArea
)
244 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
245 aSet
.Put (SvxGradientListItem(pGradientList
,SID_GRADIENT_LIST
));
246 aSet
.Put (SvxHatchListItem(pHatchingList
,SID_HATCH_LIST
));
247 aSet
.Put (SvxBitmapListItem(pBitmapList
,SID_BITMAP_LIST
));
248 aSet
.Put (SvxPatternListItem(pPatternList
,SID_PATTERN_LIST
));
249 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
250 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
251 aSet
.Put (SfxUInt16Item(SID_TABPAGE_POS
,0));
252 rPage
.PageCreated(aSet
);
254 else if (nId
== mnShadow
)
256 aSet
.Put (SvxColorListItem(pColorTab
,SID_COLOR_TABLE
));
257 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
258 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
259 rPage
.PageCreated(aSet
);
261 else if (nId
== mnTransparency
)
263 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
,0));
264 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
,1));
265 rPage
.PageCreated(aSet
);
267 else if (nId
== mnFont
)
269 SvxFontListItem
aItem(*static_cast<const SvxFontListItem
*>(mpDocShell
->GetItem( SID_ATTR_CHAR_FONTLIST
) ) );
270 aSet
.Put (SvxFontListItem( aItem
.GetFontList(), SID_ATTR_CHAR_FONTLIST
));
271 rPage
.PageCreated(aSet
);
273 else if (nId
== mnEffects
)
275 rPage
.PageCreated(aSet
);
277 else if (nId
== mnTextAtt
)
279 aSet
.Put(CntUInt16Item(SID_SVXTEXTATTRPAGE_OBJKIND
, OBJ_TEXT
));
280 rPage
.PageCreated(aSet
);
282 else if (nId
== mnBackground
)
284 aSet
.Put(SfxUInt32Item(SID_FLAG_TYPE
,static_cast<sal_uInt32
>(SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR
)));
285 rPage
.PageCreated(aSet
);
289 const SfxItemSet
* SdPresLayoutTemplateDlg::GetOutputItemSet() const
293 pOutSet
->Put( *SfxTabDialog::GetOutputItemSet() );
295 const SvxNumBulletItem
*pSvxNumBulletItem
= nullptr;
296 if( SfxItemState::SET
== pOutSet
->GetItemState(EE_PARA_NUMBULLET
, false, reinterpret_cast<const SfxPoolItem
**>(&pSvxNumBulletItem
) ))
297 SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem
->GetNumRule(), *pOutSet
);
301 return SfxTabDialog::GetOutputItemSet();
304 sal_uInt16
SdPresLayoutTemplateDlg::GetOutlineLevel() const
308 case PO_OUTLINE_1
: return 0;
309 case PO_OUTLINE_2
: return 1;
310 case PO_OUTLINE_3
: return 2;
311 case PO_OUTLINE_4
: return 3;
312 case PO_OUTLINE_5
: return 4;
313 case PO_OUTLINE_6
: return 5;
314 case PO_OUTLINE_7
: return 6;
315 case PO_OUTLINE_8
: return 7;
316 case PO_OUTLINE_9
: return 8;
318 SAL_WARN( "sd", "Wrong Po! [CL]");
323 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */