Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #undef SC_DLLIMPLEMENTATION
21 :
22 : #include "scitems.hxx"
23 : #include <svx/numinf.hxx>
24 : #include <sfx2/objsh.hxx>
25 : #include <svl/style.hxx>
26 : #include <svl/cjkoptions.hxx>
27 :
28 : #include "styledlg.hxx"
29 : #include "tabpages.hxx"
30 : #include "tphf.hxx"
31 : #include "tptable.hxx"
32 : #include "scresid.hxx"
33 : #include "sc.hrc"
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>
41 :
42 0 : ScStyleDlg::ScStyleDlg( vcl::Window* pParent,
43 : SfxStyleSheetBase& rStyleBase,
44 : sal_uInt16 nRscId )
45 :
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"),
53 : rStyleBase )
54 : , nDlgRsc ( nRscId )
55 : , m_nNumberId(0)
56 : , m_nFontId(0)
57 : , m_nFontEffectId(0)
58 : , m_nAlignmentId(0)
59 : , m_nAsianId(0)
60 : , m_nBorderId(0)
61 : , m_nBackgroundId(0)
62 : , m_nProtectId(0)
63 : , m_nPageId(0)
64 : , m_nHeaderId(0)
65 : , m_nFooterId(0)
66 0 : , m_nSheetId(0)
67 : {
68 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
69 : OSL_ENSURE(pFact, "Dialog creation failed!");
70 0 : switch ( nRscId )
71 : {
72 : case RID_SCDLG_STYLES_PAR: // Zellformatvorlagen
73 : {
74 0 : SvtCJKOptions aCJKOptions;
75 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageCreatorFunc fail!");
76 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageRangesFunc fail!");
77 0 : 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 0 : 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 0 : 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 0 : m_nAlignmentId = AddTabPage("alignment", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT ));
87 0 : if ( aCJKOptions.IsAsianTypographyEnabled() )
88 : {
89 : OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
90 : OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
91 0 : m_nAsianId = AddTabPage("asiantypo", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN));
92 : }
93 : else
94 0 : RemoveTabPage("asiantypo");
95 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
96 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
97 0 : 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 0 : m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ));
101 0 : m_nProtectId = AddTabPage("protection", &ScTabPageProtection::Create, &ScTabPageProtection::GetRanges);
102 : }
103 0 : break;
104 :
105 : case RID_SCDLG_STYLES_PAGE: // Seitenvorlagen
106 : {
107 : OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), "GetTabPageCreatorFunc fail!");
108 : OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ), "GetTabPageRangesFunc fail!");
109 0 : 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 0 : 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 0 : m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
116 0 : m_nHeaderId = AddTabPage("header", &ScHeaderPage::Create, &ScHeaderPage::GetRanges );
117 0 : m_nFooterId = AddTabPage("footer", &ScFooterPage::Create, &ScFooterPage::GetRanges );
118 0 : m_nSheetId = AddTabPage("sheet", &ScTablePage::Create, &ScTablePage::GetRanges );
119 : }
120 0 : break;
121 :
122 : default:
123 : OSL_FAIL( "Family not supported" );
124 : }
125 0 : }
126 :
127 0 : void ScStyleDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage )
128 : {
129 0 : if ( nDlgRsc == RID_SCDLG_STYLES_PAR )
130 : {
131 0 : SfxObjectShell* pDocSh = SfxObjectShell::Current();
132 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
133 0 : if (nPageId == m_nNumberId)
134 : {
135 : const SfxPoolItem* pInfoItem
136 0 : = pDocSh->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
137 :
138 : OSL_ENSURE( pInfoItem, "NumberInfoItem nicht gefunden!" );
139 :
140 0 : aSet.Put (SvxNumberInfoItem( static_cast<const SvxNumberInfoItem&>(*pInfoItem) ) );
141 0 : rTabPage.PageCreated(aSet);
142 : }
143 0 : else if (nPageId == m_nFontId)
144 : {
145 : const SfxPoolItem* pInfoItem
146 0 : = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
147 :
148 : OSL_ENSURE( pInfoItem, "FontListItem nicht gefunden!" );
149 :
150 0 : aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem&>(*pInfoItem).GetFontList(), SID_ATTR_CHAR_FONTLIST));
151 0 : rTabPage.PageCreated(aSet);
152 0 : }
153 : }
154 0 : else if ( nDlgRsc == RID_SCDLG_STYLES_PAGE )
155 : {
156 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
157 0 : if (nPageId == m_nPageId)
158 : {
159 0 : aSet.Put (SfxAllEnumItem((const sal_uInt16)SID_ENUM_PAGE_MODE, SVX_PAGE_MODE_CENTER));
160 0 : rTabPage.PageCreated(aSet);
161 : }
162 0 : else if (nPageId == m_nHeaderId || nPageId == m_nFooterId)
163 : {
164 0 : static_cast<ScHFPage&>(rTabPage).SetStyleDlg( this );
165 0 : static_cast<ScHFPage&>(rTabPage).SetPageStyle( GetStyleSheet().GetName() );
166 0 : static_cast<ScHFPage&>(rTabPage).DisableDeleteQueryBox();
167 : }
168 0 : else if (nPageId == m_nBackgroundId)
169 : {
170 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
171 0 : rTabPage.PageCreated(aSet);
172 0 : }
173 : }
174 0 : }
175 :
176 0 : void ScStyleDlg::RefreshInputSet()
177 : {
178 0 : SfxItemSet* pItemSet = GetInputSetImpl();
179 0 : pItemSet->ClearItem();
180 0 : pItemSet->SetParent( GetStyleSheet().GetItemSet().GetParent() );
181 0 : }
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|