bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / dlg / prltempl.cxx
blob37e7954ce3f363e8de66b7496580e7ae69a91912
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <editeng/flstitem.hxx>
24 #include <svx/drawitem.hxx>
25 #include <svl/style.hxx>
26 #include <svx/tabline.hxx>
27 #include <editeng/bulletitem.hxx>
28 #include <editeng/eeitem.hxx>
29 #include <editeng/brushitem.hxx>
30 #include <vcl/graph.hxx>
31 #include <editeng/lrspitem.hxx>
32 #include <editeng/numitem.hxx>
33 #include <svl/cjkoptions.hxx>
35 #include "DrawDocShell.hxx"
36 #include "glob.hrc"
37 #include "sdresid.hxx"
38 #include "prltempl.hxx"
39 #include "prltempl.hrc"
40 #include "bulmaper.hxx"
41 #include <svl/intitem.hxx>
42 #include <svx/svxgrahicitem.hxx>
43 #include <svx/flagsdef.hxx>
44 #include "drawdoc.hxx"
45 #define IS_OUTLINE(x) (x >= PO_OUTLINE_1 && x <= PO_OUTLINE_9)
47 /**
48 * Constructor of Tab dialog: appends pages to the dialog
50 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
51 Window* pParent,
52 SdResId DlgId,
53 SfxStyleSheetBase& rStyleBase,
54 PresentationObjects _ePO,
55 SfxStyleSheetBasePool* pSSPool ) :
56 SfxTabDialog ( pParent, DlgId ),
57 mpDocShell ( pDocSh ),
58 ePO ( _ePO ),
59 aInputSet ( *rStyleBase.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ),
60 pOutSet ( NULL ),
61 pOrgSet ( &rStyleBase.GetItemSet() )
63 if( IS_OUTLINE(ePO))
65 // Unfortunately, the Itemsets of our style sheets are not discreet..
66 const sal_uInt16* pPtr = pOrgSet->GetRanges();
67 sal_uInt16 p1, p2;
68 while( *pPtr )
70 p1 = pPtr[0];
71 p2 = pPtr[1];
73 // first, we make it discreet
74 while(pPtr[2] && (pPtr[2] - p2 == 1))
76 p2 = pPtr[3];
77 pPtr += 2;
79 aInputSet.MergeRange( p1, p2 );
80 pPtr += 2;
83 aInputSet.Put( rStyleBase.GetItemSet() );
85 // need parent-relationship
86 const SfxItemSet* pParentItemSet = rStyleBase.GetItemSet().GetParent();
87 if( pParentItemSet )
88 aInputSet.SetParent( pParentItemSet );
90 pOutSet = new SfxItemSet( rStyleBase.GetItemSet() );
91 pOutSet->ClearItem();
93 const SfxPoolItem *pItem = NULL;
95 // If there is no bullet item in this stylesheet, we get it
96 // from 'Outline 1' style sheet.
97 if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem ))
99 String aStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
100 aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
101 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
103 if(pFirstStyleSheet)
104 if( SFX_ITEM_SET == pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem) )
105 aInputSet.Put( *pItem );
108 // preselect selected layer in dialog
109 aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel()));
111 SetInputSet( &aInputSet );
113 else
114 SetInputSet( pOrgSet );
116 FreeResource();
118 SvxColorListItem aColorListItem(*( (const SvxColorListItem*)
119 ( mpDocShell->GetItem( SID_COLOR_TABLE ) ) ) );
120 SvxGradientListItem aGradientListItem(*( (const SvxGradientListItem*)
121 ( mpDocShell->GetItem( SID_GRADIENT_LIST ) ) ) );
122 SvxBitmapListItem aBitmapListItem(*( (const SvxBitmapListItem*)
123 ( mpDocShell->GetItem( SID_BITMAP_LIST ) ) ) );
124 SvxHatchListItem aHatchListItem(*( (const SvxHatchListItem*)
125 ( mpDocShell->GetItem( SID_HATCH_LIST ) ) ) );
126 SvxDashListItem aDashListItem(*( (const SvxDashListItem*)
127 ( mpDocShell->GetItem( SID_DASH_LIST ) ) ) );
128 SvxLineEndListItem aLineEndListItem(*( (const SvxLineEndListItem*)
129 ( mpDocShell->GetItem( SID_LINEEND_LIST ) ) ) );
131 pColorTab = aColorListItem.GetColorList();
132 pDashList = aDashListItem.GetDashList();
133 pLineEndList = aLineEndListItem.GetLineEndList();
134 pGradientList = aGradientListItem.GetGradientList();
135 pHatchingList = aHatchListItem.GetHatchList();
136 pBitmapList = aBitmapListItem.GetBitmapList();
138 switch( DlgId.GetId() )
140 case TAB_PRES_LAYOUT_TEMPLATE:
142 AddTabPage( RID_SVXPAGE_LINE);
143 AddTabPage( RID_SVXPAGE_AREA);
144 AddTabPage( RID_SVXPAGE_SHADOW);
145 AddTabPage( RID_SVXPAGE_TRANSPARENCE);
146 AddTabPage( RID_SVXPAGE_CHAR_NAME );
147 AddTabPage( RID_SVXPAGE_CHAR_EFFECTS );
148 AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
149 AddTabPage( RID_SVXPAGE_TEXTATTR );
150 AddTabPage( RID_SVXPAGE_PICK_BULLET );
151 AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
152 AddTabPage( RID_SVXPAGE_PICK_BMP );
153 AddTabPage( RID_SVXPAGE_NUM_OPTIONS );
154 AddTabPage( RID_SVXPAGE_TABULATOR );
156 break;
158 case TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND: // background
159 AddTabPage( RID_SVXPAGE_AREA);
160 break;
163 // the tabpages Alignment, Tabs and Asian Typography are very
164 // useful, except for the background style
165 if( DlgId.GetId() != TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND )
167 SvtCJKOptions aCJKOptions;
168 if( aCJKOptions.IsAsianTypographyEnabled() )
169 AddTabPage( RID_SVXPAGE_PARA_ASIAN );
170 else
171 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
173 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
176 // set title and add corresponding pages to dialog
177 OUString aTitle;
179 switch( ePO )
181 case PO_TITLE:
182 aTitle = OUString(SdResId( STR_PSEUDOSHEET_TITLE ));
183 break;
185 case PO_SUBTITLE:
186 aTitle = OUString(SdResId( STR_PSEUDOSHEET_SUBTITLE ));
187 break;
189 case PO_BACKGROUND:
190 aTitle = OUString(SdResId( STR_PSEUDOSHEET_BACKGROUND ));
191 break;
193 case PO_BACKGROUNDOBJECTS:
194 aTitle = OUString(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS ));
195 break;
197 case PO_OUTLINE_1:
198 case PO_OUTLINE_2:
199 case PO_OUTLINE_3:
200 case PO_OUTLINE_4:
201 case PO_OUTLINE_5:
202 case PO_OUTLINE_6:
203 case PO_OUTLINE_7:
204 case PO_OUTLINE_8:
205 case PO_OUTLINE_9:
206 aTitle = OUString(SdResId( STR_PSEUDOSHEET_OUTLINE )) + " " +
207 OUString::valueOf( static_cast<sal_Int32>( ePO - PO_OUTLINE_1 + 1 ) );
208 break;
210 case PO_NOTES:
211 aTitle = OUString(SdResId( STR_PSEUDOSHEET_NOTES ));
212 break;
214 SetText( aTitle );
216 nDlgType = 1; // template dialog
217 nPageType = 0;
218 nPos = 0;
220 nColorTableState = CT_NONE;
221 nBitmapListState = CT_NONE;
222 nGradientListState = CT_NONE;
223 nHatchingListState = CT_NONE;
226 // -----------------------------------------------------------------------
228 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
230 delete pOutSet;
233 // -----------------------------------------------------------------------
235 void SdPresLayoutTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
236 { SfxAllItemSet aSet(*(aInputSet.GetPool()));
237 switch( nId )
239 case RID_SVXPAGE_LINE:
241 aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
242 aSet.Put (SvxDashListItem(pDashList,SID_DASH_LIST));
243 aSet.Put (SvxLineEndListItem(pLineEndList,SID_LINEEND_LIST));
244 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
246 rPage.PageCreated(aSet);
248 break;
250 case RID_SVXPAGE_AREA:
252 aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
253 aSet.Put (SvxGradientListItem(pGradientList,SID_GRADIENT_LIST));
254 aSet.Put (SvxHatchListItem(pHatchingList,SID_HATCH_LIST));
255 aSet.Put (SvxBitmapListItem(pBitmapList,SID_BITMAP_LIST));
256 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
257 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
258 aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,nPos));
259 rPage.PageCreated(aSet);
262 break;
264 case RID_SVXPAGE_SHADOW:
265 aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
266 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
267 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
268 rPage.PageCreated(aSet);
269 break;
271 case RID_SVXPAGE_TRANSPARENCE:
272 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
273 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
274 rPage.PageCreated(aSet);
275 break;
277 case RID_SVXPAGE_CHAR_NAME:
279 SvxFontListItem aItem(*( (const SvxFontListItem*)
280 ( mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
282 aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
283 rPage.PageCreated(aSet);
285 break;
287 case RID_SVXPAGE_CHAR_EFFECTS:
288 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
289 rPage.PageCreated(aSet);
290 break;
292 case RID_SVXPAGE_STD_PARAGRAPH:
293 break;
297 const SfxItemSet* SdPresLayoutTemplateDlg::GetOutputItemSet() const
299 if( pOutSet )
301 pOutSet->Put( *SfxTabDialog::GetOutputItemSet() );
303 const SvxNumBulletItem *pSvxNumBulletItem = NULL;
304 if( SFX_ITEM_SET == pOutSet->GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pSvxNumBulletItem ))
305 SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem->GetNumRule(), *pOutSet );
306 return pOutSet;
308 else
309 return SfxTabDialog::GetOutputItemSet();
312 // ---------------------------------------------------------------------
313 // ---------------------------------------------------------------------
314 sal_uInt16 SdPresLayoutTemplateDlg::GetOutlineLevel() const
316 switch( ePO )
318 case PO_OUTLINE_1: return 0;
319 case PO_OUTLINE_2: return 1;
320 case PO_OUTLINE_3: return 2;
321 case PO_OUTLINE_4: return 3;
322 case PO_OUTLINE_5: return 4;
323 case PO_OUTLINE_6: return 5;
324 case PO_OUTLINE_7: return 6;
325 case PO_OUTLINE_8: return 7;
326 case PO_OUTLINE_9: return 8;
327 default:
328 DBG_ASSERT( sal_False, "Wrong Po! [CL]");
330 return 0;
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */