LibreOffice Module sc (master) 1
attrdlg.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 <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#include <comphelper/lok.hxx>
35
36ScAttrDlg::ScAttrDlg(weld::Window* pParent, const SfxItemSet* pCellAttrs)
37 : SfxTabDialogController(pParent, "modules/scalc/ui/formatcellsdialog.ui",
38 "FormatCellsDialog", pCellAttrs)
39{
40 // tdf#149598 - restore window state of the dialog
41 SvtViewOptions aDlgOpt(EViewType::Dialog, "FormatCellDialog");
42 if (aDlgOpt.Exists())
43 m_xDialog->set_window_state(aDlgOpt.GetWindowState());
44
46
47 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageCreatorFunc fail!");
48 AddTabPage( "numbers", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), nullptr );
49 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
50 AddTabPage( "font", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), nullptr );
51 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
52 AddTabPage( "fonteffects", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), nullptr );
53 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), "GetTabPageCreatorFunc fail!");
54 AddTabPage( "alignment", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), nullptr );
55
57 {
58 OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
59 AddTabPage( "asiantypography", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), nullptr );
60 }
61 else
62 RemoveTabPage( "asiantypography" );
63 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
64 AddTabPage( "borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), nullptr );
65 OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ), "GetTabPageCreatorFunc fail!");
66 AddTabPage( "background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ), nullptr );
67
69 AddTabPage( "cellprotection" , ScTabPageProtection::Create, nullptr );
70 else
71 RemoveTabPage( "cellprotection" );
72}
73
75{
76 // tdf#149598 - remember window state of the dialog
77 SvtViewOptions aDlgOpt(EViewType::Dialog, "FormatCellDialog");
78 aDlgOpt.SetWindowState(m_xDialog->get_window_state(vcl::WindowDataMask::PosSize));
79}
80
81void ScAttrDlg::PageCreated(const OUString& rPageId, SfxTabPage& rTabPage)
82{
84 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
85 if (rPageId == "numbers")
86 {
87 rTabPage.PageCreated(aSet);
88 }
89 else if (rPageId == "font" && pDocSh)
90 {
91 const SfxPoolItem* pInfoItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
92 assert(pInfoItem && "FontListItem not found :-(");
93 aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem*>(pInfoItem)->GetFontList(), SID_ATTR_CHAR_FONTLIST ));
94 rTabPage.PageCreated(aSet);
95 }
96 else if (rPageId == "background")
97 {
98 rTabPage.PageCreated(aSet);
99 }
100}
101
102/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
ScAttrDlg(weld::Window *pParent, const SfxItemSet *pCellAttrs)
Definition: attrdlg.cxx:36
virtual void PageCreated(const OUString &rPageId, SfxTabPage &rTabPage) override
Definition: attrdlg.cxx:81
virtual ~ScAttrDlg() override
Definition: attrdlg.cxx:74
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: tabpages.cxx:56
static SfxAbstractDialogFactory * Create()
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void RemoveTabPage(const OUString &rName)
SfxItemSet * GetInputSetImpl()
virtual void PageCreated(const SfxAllItemSet &aSet)
void SetWindowState(const OUString &sState)
OUString GetWindowState() const
bool Exists() const
bool IsAsianTypographyEnabled()