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 <sfx2/objsh.hxx>
23 #include <sfx2/tabdlg.hxx>
24 #include <sfx2/sfxdlg.hxx>
25 #include <svl/cjkoptions.hxx>
26 
27 #include <tabpages.hxx>
28 #include <attrdlg.hxx>
29 #include <svx/dialogs.hrc>
30 #include <editeng/editids.hrc>
31 #include <editeng/flstitem.hxx>
32 #include <osl/diagnose.h>
33 
ScAttrDlg(weld::Window * pParent,const SfxItemSet * pCellAttrs)34 ScAttrDlg::ScAttrDlg(weld::Window* pParent, const SfxItemSet* pCellAttrs)
35     : SfxTabDialogController(pParent, "modules/scalc/ui/formatcellsdialog.ui",
36                              "FormatCellsDialog", pCellAttrs)
37 {
38     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
39 
40     OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageCreatorFunc fail!");
41     AddTabPage( "numbers", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), nullptr );
42     OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
43     AddTabPage( "font", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), nullptr );
44     OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
45     AddTabPage( "fonteffects", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), nullptr );
46     OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), "GetTabPageCreatorFunc fail!");
47     AddTabPage( "alignment", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ),    nullptr );
48 
49     SvtCJKOptions aCJKOptions;
50     if (aCJKOptions.IsAsianTypographyEnabled())
51     {
52         OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
53         AddTabPage( "asiantypography",   pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),       nullptr );
54     }
55     else
56         RemoveTabPage( "asiantypography" );
57     OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
58     AddTabPage( "borders",      pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ),     nullptr );
59     OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ), "GetTabPageCreatorFunc fail!");
60     AddTabPage( "background",  pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ), nullptr );
61     AddTabPage( "cellprotection" ,  ScTabPageProtection::Create,    nullptr );
62 }
63 
~ScAttrDlg()64 ScAttrDlg::~ScAttrDlg()
65 {
66 }
67 
PageCreated(const OString & rPageId,SfxTabPage & rTabPage)68 void ScAttrDlg::PageCreated(const OString& rPageId, SfxTabPage& rTabPage)
69 {
70     SfxObjectShell* pDocSh = SfxObjectShell::Current();
71     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
72     if (rPageId == "numbers")
73     {
74         rTabPage.PageCreated(aSet);
75     }
76     else if (rPageId == "font")
77     {
78         const SfxPoolItem* pInfoItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
79         assert(pInfoItem && "FontListItem  not found :-(");
80         aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem*>(pInfoItem)->GetFontList(), SID_ATTR_CHAR_FONTLIST ));
81         rTabPage.PageCreated(aSet);
82     }
83     else if (rPageId == "background")
84     {
85         rTabPage.PageCreated(aSet);
86     }
87 }
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
90