merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / sd / source / ui / dlg / prltempl.cxx
blobaade684acacd552252a13e82151223246d363db1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
32 #ifdef SD_DLLIMPLEMENTATION
33 #undef SD_DLLIMPLEMENTATION
34 #endif
37 #include "eetext.hxx"
39 #include <svx/dialogs.hrc>
40 #include <editeng/flstitem.hxx>
41 #include <svx/drawitem.hxx>
42 #include <svl/style.hxx>
43 #include <svx/tabline.hxx>
44 #include <editeng/bulitem.hxx>
45 #include <editeng/eeitem.hxx>
46 #include <editeng/brshitem.hxx>
47 #include <vcl/graph.hxx>
48 #include <editeng/lrspitem.hxx>
49 #include <editeng/numitem.hxx>
50 #include <svl/cjkoptions.hxx>
52 #include "DrawDocShell.hxx"
53 #include "glob.hrc"
54 #include "sdresid.hxx"
55 #include "prltempl.hxx"
56 #include "prltempl.hrc"
57 #include "enumdlg.hrc"
58 #include "bulmaper.hxx"
59 #include <svl/intitem.hxx>
60 #include <svx/svxgrahicitem.hxx>
61 #include <svx/flagsdef.hxx>
62 #include "drawdoc.hxx"
63 #define IS_OUTLINE(x) (x >= PO_OUTLINE_1 && x <= PO_OUTLINE_9)
65 /*************************************************************************
67 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
69 \************************************************************************/
71 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
72 Window* pParent,
73 SdResId DlgId,
74 SfxStyleSheetBase& rStyleBase,
75 PresentationObjects _ePO,
76 SfxStyleSheetBasePool* pSSPool ) :
77 SfxTabDialog ( pParent, DlgId ),
78 mpDocShell ( pDocSh ),
79 ePO ( _ePO ),
80 aInputSet ( *rStyleBase.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ),
81 pOutSet ( NULL ),
82 pOrgSet ( &rStyleBase.GetItemSet() )
84 if( IS_OUTLINE(ePO))
86 // Leider sind die Itemsets unserer Stylesheets nicht discret..
87 const USHORT* pPtr = pOrgSet->GetRanges();
88 USHORT p1, p2;
89 while( *pPtr )
91 p1 = pPtr[0];
92 p2 = pPtr[1];
94 // erstmal das ganze discret machen
95 while(pPtr[2] && (pPtr[2] - p2 == 1))
97 p2 = pPtr[3];
98 pPtr += 2;
100 aInputSet.MergeRange( p1, p2 );
101 pPtr += 2;
104 aInputSet.Put( rStyleBase.GetItemSet() );
106 // need parent-relationship
107 const SfxItemSet* pParentItemSet = rStyleBase.GetItemSet().GetParent();;
108 if( pParentItemSet )
109 aInputSet.SetParent( pParentItemSet );
111 pOutSet = new SfxItemSet( rStyleBase.GetItemSet() );
112 pOutSet->ClearItem();
114 const SfxPoolItem *pItem = NULL;
116 // Fals in diesem Stylesheet kein Bullet Item ist, holen wir uns
117 // das aus dem 'Outline 1' Stylesheet.
118 if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET, FALSE, &pItem ))
120 String aStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
121 aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
122 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
124 if(pFirstStyleSheet)
125 if( SFX_ITEM_SET == pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, FALSE, &pItem) )
126 aInputSet.Put( *pItem );
129 // gewaehlte Ebene im Dialog vorselektieren
130 aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel()));
132 SetInputSet( &aInputSet );
134 else
135 SetInputSet( pOrgSet );
137 FreeResource();
139 SvxColorTableItem aColorTableItem(*( (const SvxColorTableItem*)
140 ( mpDocShell->GetItem( SID_COLOR_TABLE ) ) ) );
141 SvxGradientListItem aGradientListItem(*( (const SvxGradientListItem*)
142 ( mpDocShell->GetItem( SID_GRADIENT_LIST ) ) ) );
143 SvxBitmapListItem aBitmapListItem(*( (const SvxBitmapListItem*)
144 ( mpDocShell->GetItem( SID_BITMAP_LIST ) ) ) );
145 SvxHatchListItem aHatchListItem(*( (const SvxHatchListItem*)
146 ( mpDocShell->GetItem( SID_HATCH_LIST ) ) ) );
147 SvxDashListItem aDashListItem(*( (const SvxDashListItem*)
148 ( mpDocShell->GetItem( SID_DASH_LIST ) ) ) );
149 SvxLineEndListItem aLineEndListItem(*( (const SvxLineEndListItem*)
150 ( mpDocShell->GetItem( SID_LINEEND_LIST ) ) ) );
152 pColorTab = aColorTableItem.GetColorTable();
153 pDashList = aDashListItem.GetDashList();
154 pLineEndList = aLineEndListItem.GetLineEndList();
155 pGradientList = aGradientListItem.GetGradientList();
156 pHatchingList = aHatchListItem.GetHatchList();
157 pBitmapList = aBitmapListItem.GetBitmapList();
159 switch( DlgId.GetId() )
161 case TAB_PRES_LAYOUT_TEMPLATE:
163 AddTabPage( RID_SVXPAGE_LINE);
164 AddTabPage( RID_SVXPAGE_AREA);
165 AddTabPage( RID_SVXPAGE_SHADOW);
166 AddTabPage( RID_SVXPAGE_TRANSPARENCE);
167 AddTabPage( RID_SVXPAGE_CHAR_NAME );
168 AddTabPage( RID_SVXPAGE_CHAR_EFFECTS );
169 AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
170 AddTabPage( RID_SVXPAGE_TEXTATTR );
171 AddTabPage( RID_SVXPAGE_PICK_BULLET );
172 AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
173 AddTabPage( RID_SVXPAGE_PICK_BMP );
174 AddTabPage( RID_SVXPAGE_NUM_OPTIONS );
175 AddTabPage( RID_SVXPAGE_TABULATOR );
177 break;
179 case TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND: // background
180 AddTabPage( RID_SVXPAGE_AREA);
181 break;
184 // #112490# the tabpages Alignment, Tabs and Asian Typography are very
185 // usefull, except for the background style
186 if( DlgId.GetId() != TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND )
188 SvtCJKOptions aCJKOptions;
189 if( aCJKOptions.IsAsianTypographyEnabled() )
190 AddTabPage( RID_SVXPAGE_PARA_ASIAN );
191 else
192 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
194 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
197 // Titel setzen und
198 // entsprechende Seiten zum Dialog hinzufuegen
199 String aTitle;
201 switch( ePO )
203 case PO_TITLE:
204 aTitle = String(SdResId( STR_PSEUDOSHEET_TITLE ));
205 break;
207 case PO_SUBTITLE:
208 aTitle = String(SdResId( STR_PSEUDOSHEET_SUBTITLE ));
209 break;
211 case PO_BACKGROUND:
212 aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUND ));
213 break;
215 case PO_BACKGROUNDOBJECTS:
216 aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS ));
217 break;
219 case PO_OUTLINE_1:
220 case PO_OUTLINE_2:
221 case PO_OUTLINE_3:
222 case PO_OUTLINE_4:
223 case PO_OUTLINE_5:
224 case PO_OUTLINE_6:
225 case PO_OUTLINE_7:
226 case PO_OUTLINE_8:
227 case PO_OUTLINE_9:
228 aTitle = String(SdResId( STR_PSEUDOSHEET_OUTLINE ));
229 aTitle.Append( sal_Unicode(' ') );
230 aTitle.Append( UniString::CreateFromInt32( ePO - PO_OUTLINE_1 + 1 ) );
231 break;
233 case PO_NOTES:
234 aTitle = String(SdResId( STR_PSEUDOSHEET_NOTES ));
235 break;
237 SetText( aTitle );
239 nDlgType = 1; // Vorlagen-Dialog
240 nPageType = 0;
241 nPos = 0;
243 nColorTableState = CT_NONE;
244 nBitmapListState = CT_NONE;
245 nGradientListState = CT_NONE;
246 nHatchingListState = CT_NONE;
249 // -----------------------------------------------------------------------
251 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
253 delete pOutSet;
256 // -----------------------------------------------------------------------
258 void SdPresLayoutTemplateDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
259 { SfxAllItemSet aSet(*(aInputSet.GetPool()));
260 switch( nId )
262 case RID_SVXPAGE_LINE:
264 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE));
265 aSet.Put (SvxDashListItem(pDashList,SID_DASH_LIST));
266 aSet.Put (SvxLineEndListItem(pLineEndList,SID_LINEEND_LIST));
267 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
269 rPage.PageCreated(aSet);
271 break;
273 case RID_SVXPAGE_AREA:
275 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE));
276 aSet.Put (SvxGradientListItem(pGradientList,SID_GRADIENT_LIST));
277 aSet.Put (SvxHatchListItem(pHatchingList,SID_HATCH_LIST));
278 aSet.Put (SvxBitmapListItem(pBitmapList,SID_BITMAP_LIST));
279 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
280 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
281 aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,nPos));
282 rPage.PageCreated(aSet);
285 break;
287 case RID_SVXPAGE_SHADOW:
288 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE));
289 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
290 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
291 rPage.PageCreated(aSet);
292 break;
294 case RID_SVXPAGE_TRANSPARENCE:
295 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
296 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
297 rPage.PageCreated(aSet);
298 break;
300 case RID_SVXPAGE_CHAR_NAME:
302 SvxFontListItem aItem(*( (const SvxFontListItem*)
303 ( mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
305 aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
306 rPage.PageCreated(aSet);
308 break;
310 case RID_SVXPAGE_CHAR_EFFECTS:
311 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
312 rPage.PageCreated(aSet);
313 break;
315 case RID_SVXPAGE_STD_PARAGRAPH:
316 break;
320 const SfxItemSet* SdPresLayoutTemplateDlg::GetOutputItemSet() const
322 if( pOutSet )
324 pOutSet->Put( *SfxTabDialog::GetOutputItemSet() );
326 const SvxNumBulletItem *pSvxNumBulletItem = NULL;
327 if( SFX_ITEM_SET == pOutSet->GetItemState(EE_PARA_NUMBULLET, FALSE, (const SfxPoolItem**)&pSvxNumBulletItem ))
328 SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem->GetNumRule(), *pOutSet );
329 return pOutSet;
331 else
332 return SfxTabDialog::GetOutputItemSet();
335 // ---------------------------------------------------------------------
336 // ---------------------------------------------------------------------
337 USHORT SdPresLayoutTemplateDlg::GetOutlineLevel() const
339 switch( ePO )
341 case PO_OUTLINE_1: return 0;
342 case PO_OUTLINE_2: return 1;
343 case PO_OUTLINE_3: return 2;
344 case PO_OUTLINE_4: return 3;
345 case PO_OUTLINE_5: return 4;
346 case PO_OUTLINE_6: return 5;
347 case PO_OUTLINE_7: return 6;
348 case PO_OUTLINE_8: return 7;
349 case PO_OUTLINE_9: return 8;
350 default:
351 DBG_ASSERT( FALSE, "Falscher Po! [CL]");
353 return 0;
358 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */