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 <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"
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)
48 * Constructor of Tab dialog: appends pages to the dialog
50 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell
* pDocSh
,
53 SfxStyleSheetBase
& rStyleBase
,
54 PresentationObjects _ePO
,
55 SfxStyleSheetBasePool
* pSSPool
) :
56 SfxTabDialog ( pParent
, DlgId
),
57 mpDocShell ( pDocSh
),
59 aInputSet ( *rStyleBase
.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET
, SID_PARAM_CUR_NUM_LEVEL
),
61 pOrgSet ( &rStyleBase
.GetItemSet() )
65 // Unfortunately, the Itemsets of our style sheets are not discreet..
66 const sal_uInt16
* pPtr
= pOrgSet
->GetRanges();
73 // first, we make it discreet
74 while(pPtr
[2] && (pPtr
[2] - p2
== 1))
79 aInputSet
.MergeRange( p1
, p2
);
83 aInputSet
.Put( rStyleBase
.GetItemSet() );
85 // need parent-relationship
86 const SfxItemSet
* pParentItemSet
= rStyleBase
.GetItemSet().GetParent();
88 aInputSet
.SetParent( pParentItemSet
);
90 pOutSet
= new SfxItemSet( rStyleBase
.GetItemSet() );
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
);
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
);
114 SetInputSet( pOrgSet
);
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
);
158 case TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND
: // background
159 AddTabPage( RID_SVXPAGE_AREA
);
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
);
171 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN
);
173 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH
);
176 // set title and add corresponding pages to dialog
182 aTitle
= OUString(SdResId( STR_PSEUDOSHEET_TITLE
));
186 aTitle
= OUString(SdResId( STR_PSEUDOSHEET_SUBTITLE
));
190 aTitle
= OUString(SdResId( STR_PSEUDOSHEET_BACKGROUND
));
193 case PO_BACKGROUNDOBJECTS
:
194 aTitle
= OUString(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS
));
206 aTitle
= OUString(SdResId( STR_PSEUDOSHEET_OUTLINE
)) + " " +
207 OUString::valueOf( static_cast<sal_Int32
>( ePO
- PO_OUTLINE_1
+ 1 ) );
211 aTitle
= OUString(SdResId( STR_PSEUDOSHEET_NOTES
));
216 nDlgType
= 1; // template dialog
220 nColorTableState
= CT_NONE
;
221 nBitmapListState
= CT_NONE
;
222 nGradientListState
= CT_NONE
;
223 nHatchingListState
= CT_NONE
;
226 // -----------------------------------------------------------------------
228 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
233 // -----------------------------------------------------------------------
235 void SdPresLayoutTemplateDlg::PageCreated( sal_uInt16 nId
, SfxTabPage
&rPage
)
236 { SfxAllItemSet
aSet(*(aInputSet
.GetPool()));
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
);
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
);
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
);
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
);
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
);
287 case RID_SVXPAGE_CHAR_EFFECTS
:
288 aSet
.Put (SfxUInt16Item(SID_DISABLE_CTL
,DISABLE_CASEMAP
));
289 rPage
.PageCreated(aSet
);
292 case RID_SVXPAGE_STD_PARAGRAPH
:
297 const SfxItemSet
* SdPresLayoutTemplateDlg::GetOutputItemSet() const
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
);
309 return SfxTabDialog::GetOutputItemSet();
312 // ---------------------------------------------------------------------
313 // ---------------------------------------------------------------------
314 sal_uInt16
SdPresLayoutTemplateDlg::GetOutlineLevel() const
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;
328 DBG_ASSERT( sal_False
, "Wrong Po! [CL]");
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */