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 "scitems.hxx"
23 #include <svx/numinf.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <svl/style.hxx>
26 #include <svl/cjkoptions.hxx>
28 #include "styledlg.hxx"
29 #include "tabpages.hxx"
31 #include "tptable.hxx"
32 #include "scresid.hxx"
34 #include <svx/svxdlg.hxx>
35 #include <svx/svxids.hrc>
36 #include <svx/dialogs.hrc>
37 #include <svl/intitem.hxx>
38 #include <editeng/flstitem.hxx>
39 #include <svl/aeitem.hxx>
40 #include <svx/flagsdef.hxx>
42 ScStyleDlg::ScStyleDlg( vcl::Window
* pParent
,
43 SfxStyleSheetBase
& rStyleBase
,
46 : SfxStyleDialog ( pParent
,
47 nRscId
== RID_SCDLG_STYLES_PAR
?
48 OUString("ParaTemplateDialog") :
49 OUString("PageTemplateDialog"),
50 nRscId
== RID_SCDLG_STYLES_PAR
?
51 OUString("modules/scalc/ui/paratemplatedialog.ui") :
52 OUString("modules/scalc/ui/pagetemplatedialog.ui"),
68 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
69 OSL_ENSURE(pFact
, "Dialog creation failed!");
72 case RID_SCDLG_STYLES_PAR
: // Zellformatvorlagen
74 SvtCJKOptions aCJKOptions
;
75 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT
), "GetTabPageCreatorFunc fail!");
76 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT
), "GetTabPageRangesFunc fail!");
77 m_nNumberId
= AddTabPage("numbers", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT
));
78 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME
), "GetTabPageCreatorFunc fail!");
79 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME
), "GetTabPageRangesFunc fail!");
80 m_nFontId
= AddTabPage("font", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME
));
81 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS
), "GetTabPageCreatorFunc fail!");
82 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS
), "GetTabPageRangesFunc fail!");
83 m_nFontEffectId
= AddTabPage("fonteffects", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS
));
84 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT
), "GetTabPageCreatorFunc fail!");
85 OSL_ENSURE( pFact
->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT
), "GetTabPageRangesFunc fail!");
86 m_nAlignmentId
= AddTabPage("alignment", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT
));
87 if ( aCJKOptions
.IsAsianTypographyEnabled() )
89 OSL_ENSURE(pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN
), "GetTabPageCreatorFunc fail!");
90 OSL_ENSURE(pFact
->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN
), "GetTabPageRangesFunc fail!");
91 m_nAsianId
= AddTabPage("asiantypo", pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN
), pFact
->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN
));
94 RemoveTabPage("asiantypo");
95 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), "GetTabPageCreatorFunc fail!");
96 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
), "GetTabPageRangesFunc fail!");
97 m_nBorderId
= AddTabPage("borders", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
));
98 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), "GetTabPageCreatorFunc fail!");
99 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND
), "GetTabPageRangesFunc fail!");
100 m_nBackgroundId
= AddTabPage("background", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND
));
101 m_nProtectId
= AddTabPage("protection", &ScTabPageProtection::Create
, &ScTabPageProtection::GetRanges
);
105 case RID_SCDLG_STYLES_PAGE
: // Seitenvorlagen
107 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE
), "GetTabPageCreatorFunc fail!");
108 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_PAGE
), "GetTabPageRangesFunc fail!");
109 m_nPageId
= AddTabPage("page", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_PAGE
) );
110 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), "GetTabPageCreatorFunc fail!");
111 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
), "GetTabPageRangesFunc fail!");
112 m_nBorderId
= AddTabPage("borders", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BORDER
) );
113 OSL_ENSURE(pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), "GetTabPageCreatorFunc fail!");
114 OSL_ENSURE(pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND
), "GetTabPageRangesFunc fail!");
115 m_nBackgroundId
= AddTabPage("background", pFact
->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND
), pFact
->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND
) );
116 m_nHeaderId
= AddTabPage("header", &ScHeaderPage::Create
, &ScHeaderPage::GetRanges
);
117 m_nFooterId
= AddTabPage("footer", &ScFooterPage::Create
, &ScFooterPage::GetRanges
);
118 m_nSheetId
= AddTabPage("sheet", &ScTablePage::Create
, &ScTablePage::GetRanges
);
123 OSL_FAIL( "Family not supported" );
127 void ScStyleDlg::PageCreated( sal_uInt16 nPageId
, SfxTabPage
& rTabPage
)
129 if ( nDlgRsc
== RID_SCDLG_STYLES_PAR
)
131 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
132 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
133 if (nPageId
== m_nNumberId
)
135 const SfxPoolItem
* pInfoItem
136 = pDocSh
->GetItem( SID_ATTR_NUMBERFORMAT_INFO
);
138 OSL_ENSURE( pInfoItem
, "NumberInfoItem nicht gefunden!" );
140 aSet
.Put (SvxNumberInfoItem( static_cast<const SvxNumberInfoItem
&>(*pInfoItem
) ) );
141 rTabPage
.PageCreated(aSet
);
143 else if (nPageId
== m_nFontId
)
145 const SfxPoolItem
* pInfoItem
146 = pDocSh
->GetItem( SID_ATTR_CHAR_FONTLIST
);
148 OSL_ENSURE( pInfoItem
, "FontListItem nicht gefunden!" );
150 aSet
.Put (SvxFontListItem(static_cast<const SvxFontListItem
&>(*pInfoItem
).GetFontList(), SID_ATTR_CHAR_FONTLIST
));
151 rTabPage
.PageCreated(aSet
);
154 else if ( nDlgRsc
== RID_SCDLG_STYLES_PAGE
)
156 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
157 if (nPageId
== m_nPageId
)
159 aSet
.Put (SfxAllEnumItem((const sal_uInt16
)SID_ENUM_PAGE_MODE
, SVX_PAGE_MODE_CENTER
));
160 rTabPage
.PageCreated(aSet
);
162 else if (nPageId
== m_nHeaderId
|| nPageId
== m_nFooterId
)
164 static_cast<ScHFPage
&>(rTabPage
).SetStyleDlg( this );
165 static_cast<ScHFPage
&>(rTabPage
).SetPageStyle( GetStyleSheet().GetName() );
166 static_cast<ScHFPage
&>(rTabPage
).DisableDeleteQueryBox();
168 else if (nPageId
== m_nBackgroundId
)
170 aSet
.Put (SfxUInt32Item(SID_FLAG_TYPE
, static_cast<sal_uInt32
>(SvxBackgroundTabFlags::SHOW_SELECTOR
)));
171 rTabPage
.PageCreated(aSet
);
176 void ScStyleDlg::RefreshInputSet()
178 SfxItemSet
* pItemSet
= GetInputSetImpl();
179 pItemSet
->ClearItem();
180 pItemSet
->SetParent( GetStyleSheet().GetItemSet().GetParent() );
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */