LibreOffice Module sc (master)  1
styledlg.cxx
Go to the documentation of this file.
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 <svx/numinf.hxx>
23 #include <sfx2/objsh.hxx>
24 #include <sfx2/sfxdlg.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 <svx/svxids.hrc>
33 #include <svx/dialogs.hrc>
34 #include <svl/intitem.hxx>
35 #include <editeng/flstitem.hxx>
36 #include <svl/aeitem.hxx>
37 #include <svx/flagsdef.hxx>
38 
40  SfxStyleSheetBase& rStyleBase,
41  bool bPage)
42  : SfxStyleDialogController(pParent,
43  bPage ?
44  OUString("modules/scalc/ui/pagetemplatedialog.ui") :
45  OUString("modules/scalc/ui/paratemplatedialog.ui"),
46  bPage ?
47  OString("PageTemplateDialog") :
48  OString("ParaTemplateDialog"),
49  rStyleBase )
50  , m_bPage(bPage)
51 {
53  if (m_bPage) // page styles
54  {
55  AddTabPage("page", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ) );
56  AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
57  AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BKG ) );
61  }
62  else // cell format styles
63  {
64  SvtCJKOptions aCJKOptions;
65  AddTabPage("numbers", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT ));
66  AddTabPage("font", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ));
67  AddTabPage("fonteffects", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ));
68  AddTabPage("alignment", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT ));
69  if ( aCJKOptions.IsAsianTypographyEnabled() )
70  {
71  AddTabPage("asiantypo", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN));
72  }
73  else
74  RemoveTabPage("asiantypo");
75  AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ));
76  AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BKG ));
78  }
79 }
80 
81 void ScStyleDlg::PageCreated(const OString& rPageId, SfxTabPage& rTabPage)
82 {
83  if (m_bPage)
84  {
85  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
86  if (rPageId == "page")
87  {
88  aSet.Put (SfxUInt16Item(sal_uInt16(SID_ENUM_PAGE_MODE), SVX_PAGE_MODE_CENTER));
89  rTabPage.PageCreated(aSet);
90  }
91  else if (rPageId == "header" || rPageId == "footer")
92  {
93  static_cast<ScHFPage&>(rTabPage).SetStyleDlg( this );
94  static_cast<ScHFPage&>(rTabPage).SetPageStyle( GetStyleSheet().GetName() );
95  static_cast<ScHFPage&>(rTabPage).DisableDeleteQueryBox();
96  }
97  else if (rPageId == "background")
98  {
99  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
100  rTabPage.PageCreated(aSet);
101  }
102  }
103  else
104  {
106  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
107  if (rPageId == "numbers")
108  {
109  const SfxPoolItem* pInfoItem
110  = pDocSh->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
111 
112  OSL_ENSURE( pInfoItem, "NumberInfoItem not found!" );
113 
114  aSet.Put ( static_cast<const SvxNumberInfoItem&>(*pInfoItem) );
115  rTabPage.PageCreated(aSet);
116  }
117  else if (rPageId == "font")
118  {
119  const SfxPoolItem* pInfoItem
120  = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
121 
122  OSL_ENSURE( pInfoItem, "FontListItem not found!" );
123 
124  aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem&>(*pInfoItem).GetFontList(), SID_ATTR_CHAR_FONTLIST));
125  rTabPage.PageCreated(aSet);
126  }
127  else if (rPageId == "background")
128  {
129  rTabPage.PageCreated(aSet);
130  }
131  }
132 }
133 
135 {
136  SfxItemSet* pItemSet = GetInputSetImpl();
137  pItemSet->ClearItem();
138  pItemSet->SetParent( GetStyleSheet().GetItemSet().GetParent() );
139 }
140 
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: tphf.cxx:229
virtual void RefreshInputSet() override
Definition: styledlg.cxx:134
virtual void PageCreated(const SfxAllItemSet &aSet)
static SfxAbstractDialogFactory * Create()
void RemoveTabPage(const OString &rName)
static const sal_uInt16 * GetRanges()
Definition: tphf.cxx:234
SfxItemSet * GetInputSetImpl()
static SfxObjectShell * Current()
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rCoreSet)
Definition: tptable.cxx:145
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
const OUString & GetName() const
SfxStyleSheetBase & GetStyleSheet()
static const sal_uInt16 * GetRanges()
Definition: tabpages.hxx:34
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: tabpages.cxx:60
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
ScStyleDlg(weld::Window *pParent, SfxStyleSheetBase &rStyleBase, bool bPage)
Definition: styledlg.cxx:39
void SetParent(const SfxItemSet *pNew)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool IsAsianTypographyEnabled() const
virtual GetTabPageRanges GetTabPageRangesFunc(sal_uInt16 nId)=0
bool m_bPage
Definition: styledlg.hxx:39
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
virtual void PageCreated(const OString &rPageId, SfxTabPage &rTabPage) override
Definition: styledlg.cxx:81
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: tphf.cxx:213
SVX_PAGE_MODE_CENTER
static const sal_uInt16 * GetRanges()
Definition: tphf.cxx:218
static const sal_uInt16 * GetRanges()
Definition: tptable.hxx:33