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 #undef SC_DLLIMPLEMENTATION
22 #include <svx/drawitem.hxx>
23 #include <svx/ofaitem.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/numinf.hxx>
26 #include <sfx2/objsh.hxx>
27 #include <sfx2/sfxdlg.hxx>
28 #include <svl/style.hxx>
29 #include <svl/cjkoptions.hxx>
30 #include <osl/diagnose.h>
32 #include <styledlg.hxx>
33 #include <tabpages.hxx>
35 #include <tptable.hxx>
36 #include <svx/svxids.hrc>
37 #include <svx/dialogs.hrc>
38 #include <svl/intitem.hxx>
39 #include <editeng/flstitem.hxx>
40 #include <svx/flagsdef.hxx>
42 ScStyleDlg::ScStyleDlg(weld::Window
* pParent
,
43 SfxStyleSheetBase
& rStyleBase
,
45 : SfxStyleDialogController(pParent
,
47 u
"modules/scalc/ui/pagetemplatedialog.ui"_ustr
:
48 u
"modules/scalc/ui/paratemplatedialog.ui"_ustr
,
50 u
"PageTemplateDialog"_ustr
:
51 u
"ParaTemplateDialog"_ustr
,
55 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
56 if (m_bPage
) // page styles
58 AddTabPage(u
"page"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_PAGE
) );
59 AddTabPage(u
"borders"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
) );
60 AddTabPage(u
"background"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BKG
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BKG
) );
61 AddTabPage(u
"header"_ustr
, &ScHeaderPage::Create
, &ScHeaderPage::GetRanges
);
62 AddTabPage(u
"footer"_ustr
, &ScFooterPage::Create
, &ScFooterPage::GetRanges
);
63 AddTabPage(u
"sheet"_ustr
, &ScTablePage::Create
, &ScTablePage::GetRanges
);
65 else // cell format styles
67 AddTabPage(u
"numbers"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT
));
68 AddTabPage(u
"font"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME
));
69 AddTabPage(u
"fonteffects"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS
));
70 AddTabPage(u
"alignment"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT
));
71 if ( SvtCJKOptions::IsAsianTypographyEnabled() )
73 AddTabPage(u
"asiantypo"_ustr
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN
), pFact
->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN
));
76 RemoveTabPage(u
"asiantypo"_ustr
);
77 AddTabPage(u
"borders"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
));
78 AddTabPage(u
"background"_ustr
, pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BKG
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BKG
));
79 AddTabPage(u
"protection"_ustr
, &ScTabPageProtection::Create
, &ScTabPageProtection::GetRanges
);
83 void ScStyleDlg::PageCreated(const OUString
& rPageId
, SfxTabPage
& rTabPage
)
87 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
88 if (rPageId
== "page")
90 aSet
.Put (SfxUInt16Item(SID_ENUM_PAGE_MODE
, SVX_PAGE_MODE_CENTER
));
91 rTabPage
.PageCreated(aSet
);
93 else if (rPageId
== "header" || rPageId
== "footer")
95 static_cast<ScHFPage
&>(rTabPage
).SetStyleDlg( this );
96 static_cast<ScHFPage
&>(rTabPage
).SetPageStyle( GetStyleSheet().GetName() );
97 static_cast<ScHFPage
&>(rTabPage
).DisableDeleteQueryBox();
99 else if (rPageId
== "background")
101 aSet
.Put (SfxUInt32Item(SID_FLAG_TYPE
, static_cast<sal_uInt32
>(SvxBackgroundTabFlags::SHOW_SELECTOR
)));
102 rTabPage
.PageCreated(aSet
);
105 else if (SfxObjectShell
* pDocSh
= SfxObjectShell::Current())
107 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
108 if (rPageId
== "numbers")
110 const SfxPoolItem
* pInfoItem
111 = pDocSh
->GetItem( SID_ATTR_NUMBERFORMAT_INFO
);
113 OSL_ENSURE( pInfoItem
, "NumberInfoItem not found!" );
115 aSet
.Put ( static_cast<const SvxNumberInfoItem
&>(*pInfoItem
) );
116 rTabPage
.PageCreated(aSet
);
118 else if (rPageId
== "font")
120 const SfxPoolItem
* pInfoItem
121 = pDocSh
->GetItem( SID_ATTR_CHAR_FONTLIST
);
123 OSL_ENSURE( pInfoItem
, "FontListItem not found!" );
125 aSet
.Put (SvxFontListItem(static_cast<const SvxFontListItem
&>(*pInfoItem
).GetFontList(), SID_ATTR_CHAR_FONTLIST
));
126 rTabPage
.PageCreated(aSet
);
128 else if (rPageId
== "background")
130 rTabPage
.PageCreated(aSet
);
135 void ScStyleDlg::RefreshInputSet()
137 SfxItemSet
* pItemSet
= GetInputSetImpl();
138 pItemSet
->ClearItem();
139 pItemSet
->SetParent( GetStyleSheet().GetItemSet().GetParent() );
142 ScDrawStyleDlg::ScDrawStyleDlg(weld::Window
* pParent
, SfxStyleSheetBase
& rStyleBase
, SdrView
* pView
)
143 : SfxStyleDialogController(pParent
, u
"modules/scalc/ui/drawtemplatedialog.ui"_ustr
, u
"DrawTemplateDialog"_ustr
, rStyleBase
)
146 AddTabPage(u
"line"_ustr
, RID_SVXPAGE_LINE
);
147 AddTabPage(u
"area"_ustr
, RID_SVXPAGE_AREA
);
148 AddTabPage(u
"shadowing"_ustr
, RID_SVXPAGE_SHADOW
);
149 AddTabPage(u
"transparency"_ustr
, RID_SVXPAGE_TRANSPARENCE
);
150 AddTabPage(u
"font"_ustr
, RID_SVXPAGE_CHAR_NAME
);
151 AddTabPage(u
"fonteffect"_ustr
, RID_SVXPAGE_CHAR_EFFECTS
);
152 AddTabPage(u
"background"_ustr
, RID_SVXPAGE_BKG
);
153 AddTabPage(u
"indents"_ustr
, RID_SVXPAGE_STD_PARAGRAPH
);
154 AddTabPage(u
"text"_ustr
, RID_SVXPAGE_TEXTATTR
);
155 AddTabPage(u
"animation"_ustr
, RID_SVXPAGE_TEXTANIMATION
);
156 AddTabPage(u
"dimensioning"_ustr
, RID_SVXPAGE_MEASURE
);
157 AddTabPage(u
"alignment"_ustr
, RID_SVXPAGE_ALIGN_PARAGRAPH
);
158 AddTabPage(u
"tabs"_ustr
, RID_SVXPAGE_TABULATOR
);
159 if (SvtCJKOptions::IsAsianTypographyEnabled())
160 AddTabPage(u
"asiantypo"_ustr
, RID_SVXPAGE_PARA_ASIAN
);
162 RemoveTabPage(u
"asiantypo"_ustr
);
165 void ScDrawStyleDlg::PageCreated(const OUString
& rPageId
, SfxTabPage
& rTabPage
)
167 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
168 SdrModel
& rModel
= mpView
->GetModel();
170 if (rPageId
== "line")
172 aSet
.Put(SvxColorListItem(rModel
.GetColorList(), SID_COLOR_TABLE
));
173 aSet
.Put(SvxDashListItem(rModel
.GetDashList(), SID_DASH_LIST
));
174 aSet
.Put(SvxLineEndListItem(rModel
.GetLineEndList(), SID_LINEEND_LIST
));
175 aSet
.Put(SfxUInt16Item(SID_DLG_TYPE
, 1));
176 rTabPage
.PageCreated(aSet
);
178 else if (rPageId
== "area")
180 aSet
.Put(SvxColorListItem(rModel
.GetColorList(), SID_COLOR_TABLE
));
181 aSet
.Put(SvxGradientListItem(rModel
.GetGradientList(), SID_GRADIENT_LIST
));
182 aSet
.Put(SvxHatchListItem(rModel
.GetHatchList(), SID_HATCH_LIST
));
183 aSet
.Put(SvxBitmapListItem(rModel
.GetBitmapList(), SID_BITMAP_LIST
));
184 aSet
.Put(SvxPatternListItem(rModel
.GetPatternList(), SID_PATTERN_LIST
));
185 aSet
.Put(SfxUInt16Item(SID_PAGE_TYPE
, 0));
186 aSet
.Put(SfxUInt16Item(SID_DLG_TYPE
, 1));
187 aSet
.Put(SfxUInt16Item(SID_TABPAGE_POS
, 0));
188 rTabPage
.PageCreated(aSet
);
190 else if (rPageId
== "shadowing")
192 aSet
.Put(SvxColorListItem(rModel
.GetColorList(), SID_COLOR_TABLE
));
193 aSet
.Put(SfxUInt16Item(SID_PAGE_TYPE
, 0));
194 aSet
.Put(SfxUInt16Item(SID_DLG_TYPE
, 1));
195 rTabPage
.PageCreated(aSet
);
197 else if (rPageId
== "transparency")
199 aSet
.Put (SfxUInt16Item(SID_PAGE_TYPE
, 0));
200 aSet
.Put (SfxUInt16Item(SID_DLG_TYPE
, 1));
201 rTabPage
.PageCreated(aSet
);
203 else if (rPageId
== "font")
205 if (SfxObjectShell
* pDocSh
= SfxObjectShell::Current())
207 SvxFontListItem
aItem(*static_cast<const SvxFontListItem
*>(
208 pDocSh
->GetItem(SID_ATTR_CHAR_FONTLIST
)));
210 aSet
.Put(SvxFontListItem(aItem
.GetFontList(), SID_ATTR_CHAR_FONTLIST
));
212 rTabPage
.PageCreated(aSet
);
214 else if (rPageId
== "fonteffect")
216 rTabPage
.PageCreated(aSet
);
218 else if (rPageId
== "background")
220 aSet
.Put(SfxUInt32Item(SID_FLAG_TYPE
, static_cast<sal_uInt32
>(SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR
)));
221 rTabPage
.PageCreated(aSet
);
223 else if (rPageId
== "text")
225 rTabPage
.PageCreated(aSet
);
227 else if (rPageId
== "dimensioning")
229 aSet
.Put(OfaPtrItem(SID_OBJECT_LIST
, mpView
));
230 rTabPage
.PageCreated(aSet
);
234 void ScDrawStyleDlg::RefreshInputSet()
236 SfxItemSet
* pItemSet
= GetInputSetImpl();
237 pItemSet
->ClearItem();
238 pItemSet
->SetParent( GetStyleSheet().GetItemSet().GetParent() );
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */