1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prltempl.cxx,v $
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
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"
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
,
77 SfxStyleSheetBase
& rStyleBase
,
78 PresentationObjects _ePO
,
79 SfxStyleSheetBasePool
* pSSPool
) :
80 SfxTabDialog ( pParent
, DlgId
),
81 mpDocShell ( pDocSh
),
83 aInputSet ( *rStyleBase
.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET
, SID_PARAM_CUR_NUM_LEVEL
),
85 pOrgSet ( &rStyleBase
.GetItemSet() )
89 // Leider sind die Itemsets unserer Stylesheets nicht discret..
90 const USHORT
* pPtr
= pOrgSet
->GetRanges();
97 // erstmal das ganze discret machen
98 while(pPtr
[2] && (pPtr
[2] - p2
== 1))
103 aInputSet
.MergeRange( p1
, p2
);
107 aInputSet
.Put( rStyleBase
.GetItemSet() );
109 // need parent-relationship
110 const SfxItemSet
* pParentItemSet
= rStyleBase
.GetItemSet().GetParent();;
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
);
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
);
138 SetInputSet( pOrgSet
);
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
);
178 case TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND
: // background
179 AddTabPage( RID_SVXPAGE_AREA
);
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
);
191 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN
);
193 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH
);
197 // entsprechende Seiten zum Dialog hinzufuegen
203 aTitle
= String(SdResId( STR_PSEUDOSHEET_TITLE
));
207 aTitle
= String(SdResId( STR_PSEUDOSHEET_SUBTITLE
));
211 aTitle
= String(SdResId( STR_PSEUDOSHEET_BACKGROUND
));
214 case PO_BACKGROUNDOBJECTS
:
215 aTitle
= String(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS
));
227 aTitle
= String(SdResId( STR_PSEUDOSHEET_OUTLINE
));
228 aTitle
.Append( sal_Unicode(' ') );
229 aTitle
.Append( UniString::CreateFromInt32( ePO
- PO_OUTLINE_1
+ 1 ) );
233 aTitle
= String(SdResId( STR_PSEUDOSHEET_NOTES
));
238 nDlgType
= 1; // Vorlagen-Dialog
242 nColorTableState
= CT_NONE
;
243 nBitmapListState
= CT_NONE
;
244 nGradientListState
= CT_NONE
;
245 nHatchingListState
= CT_NONE
;
248 // -----------------------------------------------------------------------
250 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
255 // -----------------------------------------------------------------------
257 void SdPresLayoutTemplateDlg::PageCreated( USHORT nId
, SfxTabPage
&rPage
)
258 { SfxAllItemSet
aSet(*(aInputSet
.GetPool()));
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
);
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
);
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
);
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
);
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
);
309 case RID_SVXPAGE_CHAR_EFFECTS
:
310 aSet
.Put (SfxUInt16Item(SID_DISABLE_CTL
,DISABLE_CASEMAP
));
311 rPage
.PageCreated(aSet
);
314 case RID_SVXPAGE_STD_PARAGRAPH
:
319 const SfxItemSet
* SdPresLayoutTemplateDlg::GetOutputItemSet() const
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
);
331 return SfxTabDialog::GetOutputItemSet();
334 // ---------------------------------------------------------------------
335 // ---------------------------------------------------------------------
336 USHORT
SdPresLayoutTemplateDlg::GetOutlineLevel() const
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;
350 DBG_ASSERT( FALSE
, "Falscher Po! [CL]");