update dev300-m58
[ooovba.git] / sd / source / ui / dlg / prltempl.cxx
blobec587912f3d7ce8d14ce4c3a9cfaa39d50a0288e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prltempl.cxx,v $
10 * $Revision: 1.21 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
36 #endif
39 #include "eetext.hxx"
41 #include <svx/dialogs.hrc>
42 #include <svx/flstitem.hxx>
43 #include <svx/drawitem.hxx>
44 #include <svtools/style.hxx>
45 #include <svx/tabline.hxx>
46 #include <svx/bulitem.hxx>
47 #include <svx/eeitem.hxx>
48 #include <svx/brshitem.hxx>
49 #include <vcl/graph.hxx>
50 #include <svx/lrspitem.hxx>
51 #include <svx/numitem.hxx>
52 #include <svtools/cjkoptions.hxx>
54 #include "DrawDocShell.hxx"
55 #include "glob.hrc"
56 #include "sdresid.hxx"
57 #include "prltempl.hxx"
58 #include "prltempl.hrc"
59 #include "enumdlg.hrc"
60 //#include "enumdlg.hxx"
61 #include "bulmaper.hxx"
62 #include <svtools/intitem.hxx>
63 #include <svx/svxgrahicitem.hxx>
64 #include <svx/flagsdef.hxx>
65 #include "drawdoc.hxx"
66 #define IS_OUTLINE(x) (x >= PO_OUTLINE_1 && x <= PO_OUTLINE_9)
68 /*************************************************************************
70 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
72 \************************************************************************/
74 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
75 Window* pParent,
76 SdResId DlgId,
77 SfxStyleSheetBase& rStyleBase,
78 PresentationObjects _ePO,
79 SfxStyleSheetBasePool* pSSPool ) :
80 SfxTabDialog ( pParent, DlgId ),
81 mpDocShell ( pDocSh ),
82 ePO ( _ePO ),
83 aInputSet ( *rStyleBase.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ),
84 pOutSet ( NULL ),
85 pOrgSet ( &rStyleBase.GetItemSet() )
87 if( IS_OUTLINE(ePO))
89 // Leider sind die Itemsets unserer Stylesheets nicht discret..
90 const USHORT* pPtr = pOrgSet->GetRanges();
91 USHORT p1, p2;
92 while( *pPtr )
94 p1 = pPtr[0];
95 p2 = pPtr[1];
97 // erstmal das ganze discret machen
98 while(pPtr[2] && (pPtr[2] - p2 == 1))
100 p2 = pPtr[3];
101 pPtr += 2;
103 aInputSet.MergeRange( p1, p2 );
104 pPtr += 2;
107 aInputSet.Put( rStyleBase.GetItemSet() );
109 // need parent-relationship
110 const SfxItemSet* pParentItemSet = rStyleBase.GetItemSet().GetParent();;
111 if( pParentItemSet )
112 aInputSet.SetParent( pParentItemSet );
114 pOutSet = new SfxItemSet( rStyleBase.GetItemSet() );
115 pOutSet->ClearItem();
117 const SfxPoolItem *pItem = NULL;
119 // Fals in diesem Stylesheet kein Bullet Item ist, holen wir uns
120 // das aus dem 'Outline 1' Stylesheet.
121 if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET, FALSE, &pItem ))
123 String aStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
124 aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
125 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
127 if(pFirstStyleSheet)
128 if( SFX_ITEM_SET == pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, FALSE, &pItem) )
129 aInputSet.Put( *pItem );
132 // gewaehlte Ebene im Dialog vorselektieren
133 aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel()));
135 SetInputSet( &aInputSet );
137 else
138 SetInputSet( pOrgSet );
140 FreeResource();
142 SvxColorTableItem aColorTableItem(*( (const SvxColorTableItem*)
143 ( mpDocShell->GetItem( SID_COLOR_TABLE ) ) ) );
144 SvxGradientListItem aGradientListItem(*( (const SvxGradientListItem*)
145 ( mpDocShell->GetItem( SID_GRADIENT_LIST ) ) ) );
146 SvxBitmapListItem aBitmapListItem(*( (const SvxBitmapListItem*)
147 ( mpDocShell->GetItem( SID_BITMAP_LIST ) ) ) );
148 SvxHatchListItem aHatchListItem(*( (const SvxHatchListItem*)
149 ( mpDocShell->GetItem( SID_HATCH_LIST ) ) ) );
150 SvxDashListItem aDashListItem(*( (const SvxDashListItem*)
151 ( mpDocShell->GetItem( SID_DASH_LIST ) ) ) );
152 SvxLineEndListItem aLineEndListItem(*( (const SvxLineEndListItem*)
153 ( mpDocShell->GetItem( SID_LINEEND_LIST ) ) ) );
155 pColorTab = aColorTableItem.GetColorTable();
156 pDashList = aDashListItem.GetDashList();
157 pLineEndList = aLineEndListItem.GetLineEndList();
158 pGradientList = aGradientListItem.GetGradientList();
159 pHatchingList = aHatchListItem.GetHatchList();
160 pBitmapList = aBitmapListItem.GetBitmapList();
162 switch( DlgId.GetId() )
164 case TAB_PRES_LAYOUT_TEMPLATE:
166 AddTabPage( RID_SVXPAGE_LINE);
167 AddTabPage( RID_SVXPAGE_AREA);
168 AddTabPage( RID_SVXPAGE_SHADOW);
169 AddTabPage( RID_SVXPAGE_TRANSPARENCE);
170 AddTabPage( RID_SVXPAGE_CHAR_NAME );
171 AddTabPage( RID_SVXPAGE_CHAR_EFFECTS );
172 AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
173 AddTabPage( RID_SVXPAGE_TEXTATTR );
174 AddTabPage( RID_SVXPAGE_TABULATOR );
176 break;
178 case TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND: // background
179 AddTabPage( RID_SVXPAGE_AREA);
180 break;
183 // #112490# the tabpages Alignment, Tabs and Asian Typography are very
184 // usefull, except for the background style
185 if( DlgId.GetId() != TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND )
187 SvtCJKOptions aCJKOptions;
188 if( aCJKOptions.IsAsianTypographyEnabled() )
189 AddTabPage( RID_SVXPAGE_PARA_ASIAN );
190 else
191 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
193 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
196 // Titel setzen und
197 // entsprechende Seiten zum Dialog hinzufuegen
198 String aTitle;
200 switch( ePO )
202 case PO_TITLE:
203 aTitle = String(SdResId( STR_PSEUDOSHEET_TITLE ));
204 break;
206 case PO_SUBTITLE:
207 aTitle = String(SdResId( STR_PSEUDOSHEET_SUBTITLE ));
208 break;
210 case PO_BACKGROUND:
211 aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUND ));
212 break;
214 case PO_BACKGROUNDOBJECTS:
215 aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS ));
216 break;
218 case PO_OUTLINE_1:
219 case PO_OUTLINE_2:
220 case PO_OUTLINE_3:
221 case PO_OUTLINE_4:
222 case PO_OUTLINE_5:
223 case PO_OUTLINE_6:
224 case PO_OUTLINE_7:
225 case PO_OUTLINE_8:
226 case PO_OUTLINE_9:
227 aTitle = String(SdResId( STR_PSEUDOSHEET_OUTLINE ));
228 aTitle.Append( sal_Unicode(' ') );
229 aTitle.Append( UniString::CreateFromInt32( ePO - PO_OUTLINE_1 + 1 ) );
230 break;
232 case PO_NOTES:
233 aTitle = String(SdResId( STR_PSEUDOSHEET_NOTES ));
234 break;
236 SetText( aTitle );
238 nDlgType = 1; // Vorlagen-Dialog
239 nPageType = 0;
240 nPos = 0;
242 nColorTableState = CT_NONE;
243 nBitmapListState = CT_NONE;
244 nGradientListState = CT_NONE;
245 nHatchingListState = CT_NONE;
248 // -----------------------------------------------------------------------
250 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
252 delete pOutSet;
255 // -----------------------------------------------------------------------
257 void SdPresLayoutTemplateDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
258 { SfxAllItemSet aSet(*(aInputSet.GetPool()));
259 switch( nId )
261 case RID_SVXPAGE_LINE:
263 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE));
264 aSet.Put (SvxDashListItem(pDashList,SID_DASH_LIST));
265 aSet.Put (SvxLineEndListItem(pLineEndList,SID_LINEEND_LIST));
266 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
268 rPage.PageCreated(aSet);
270 break;
272 case RID_SVXPAGE_AREA:
274 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE));
275 aSet.Put (SvxGradientListItem(pGradientList,SID_GRADIENT_LIST));
276 aSet.Put (SvxHatchListItem(pHatchingList,SID_HATCH_LIST));
277 aSet.Put (SvxBitmapListItem(pBitmapList,SID_BITMAP_LIST));
278 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
279 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
280 aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,nPos));
281 rPage.PageCreated(aSet);
284 break;
286 case RID_SVXPAGE_SHADOW:
287 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE)); //add CHINA001
288 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
289 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
290 rPage.PageCreated(aSet);
291 break;
293 case RID_SVXPAGE_TRANSPARENCE:
294 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
295 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
296 rPage.PageCreated(aSet);
297 break;
299 case RID_SVXPAGE_CHAR_NAME:
301 SvxFontListItem aItem(*( (const SvxFontListItem*)
302 ( mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
304 aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
305 rPage.PageCreated(aSet);
307 break;
309 case RID_SVXPAGE_CHAR_EFFECTS:
310 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
311 rPage.PageCreated(aSet);
312 break;
314 case RID_SVXPAGE_STD_PARAGRAPH:
315 break;
319 const SfxItemSet* SdPresLayoutTemplateDlg::GetOutputItemSet() const
321 if( pOutSet )
323 pOutSet->Put( *SfxTabDialog::GetOutputItemSet() );
325 const SvxNumBulletItem *pSvxNumBulletItem = NULL;
326 if( SFX_ITEM_SET == pOutSet->GetItemState(EE_PARA_NUMBULLET, FALSE, (const SfxPoolItem**)&pSvxNumBulletItem ))
327 SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem->GetNumRule(), *pOutSet );
328 return pOutSet;
330 else
331 return SfxTabDialog::GetOutputItemSet();
334 // ---------------------------------------------------------------------
335 // ---------------------------------------------------------------------
336 USHORT SdPresLayoutTemplateDlg::GetOutlineLevel() const
338 switch( ePO )
340 case PO_OUTLINE_1: return 0;
341 case PO_OUTLINE_2: return 1;
342 case PO_OUTLINE_3: return 2;
343 case PO_OUTLINE_4: return 3;
344 case PO_OUTLINE_5: return 4;
345 case PO_OUTLINE_6: return 5;
346 case PO_OUTLINE_7: return 6;
347 case PO_OUTLINE_8: return 7;
348 case PO_OUTLINE_9: return 8;
349 default:
350 DBG_ASSERT( FALSE, "Falscher Po! [CL]");
352 return 0;