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 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_NUMFMTLB_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_NUMFMTLB_HXX
22 #include <vcl/weld.hxx>
23 #include <svl/zforlist.hxx>
28 class SW_DLLPUBLIC SwNumFormatBase
30 sal_Int32 m_nStdEntry
;
31 sal_uInt32 m_nDefFormat
;
32 SvNumFormatType m_nCurrFormatType
;
33 LanguageType m_eCurLanguage
;
35 bool mbCurrFormatTypeNeedsInit
;
36 bool m_bShowLanguageControl
; //determine whether the language control has
37 //to be shown in the number format dialog
38 bool m_bUseAutomaticLanguage
;//determine whether language is automatically assigned
42 void SetAutomaticLanguage(bool bSet
) { m_bUseAutomaticLanguage
= bSet
; }
43 bool IsAutomaticLanguage()const { return m_bUseAutomaticLanguage
; }
44 SvNumFormatType
GetFormatType() const { return m_nCurrFormatType
; }
45 LanguageType
GetCurLanguage() const { return m_eCurLanguage
;}
46 void SetLanguage(LanguageType eSet
) { m_eCurLanguage
= eSet
; }
47 void SetShowLanguageControl(bool bSet
) { m_bShowLanguageControl
= bSet
; }
48 SAL_DLLPRIVATE
static double GetDefValue(const SvNumFormatType nFormatType
);
49 void SetOneArea(bool bOnlyOne
) { m_bOneArea
= bOnlyOne
; }
51 void SetFormatType(const SvNumFormatType nFormatType
);
52 void SetDefFormat(const sal_uInt32 nDefFormat
);
53 virtual sal_uInt32
GetFormat() const = 0;
59 virtual int get_count() const = 0;
60 virtual int get_active() const = 0;
61 virtual OUString
get_id(int nPos
) const = 0;
62 virtual OUString
get_text(int nPos
) const = 0;
63 virtual weld::Widget
& get_widget() const = 0;
64 virtual void append(const OUString
& rId
, const OUString
& rText
) = 0;
65 virtual void append_text(const OUString
& rText
) = 0;
66 virtual void insert_text(int nPos
, const OUString
& rText
) = 0;
67 virtual void set_active(int nPos
) = 0;
68 virtual void set_id(int nPos
, const OUString
& rId
) = 0;
69 virtual ~SwNumFormatBase() {}
72 class SW_DLLPUBLIC NumFormatListBox final
: public SwNumFormatBase
74 std::unique_ptr
<weld::ComboBox
> mxControl
;
76 DECL_DLLPRIVATE_LINK( SelectHdl
, weld::ComboBox
&, void );
78 virtual void Init() override
;
81 NumFormatListBox(std::unique_ptr
<weld::ComboBox
> xControl
);
83 virtual sal_uInt32
GetFormat() const override
;
85 virtual void clear() override
;
86 virtual int get_count() const override
{ return mxControl
->get_count(); }
87 virtual int get_active() const override
{ return mxControl
->get_active(); }
88 virtual OUString
get_id(int nPos
) const override
{ return mxControl
->get_id(nPos
); }
89 virtual OUString
get_text(int nPos
) const override
{ return mxControl
->get_text(nPos
); }
90 virtual weld::Widget
& get_widget() const override
{ return *mxControl
; }
91 virtual void append(const OUString
& rId
, const OUString
& rText
) override
{ mxControl
->append(rId
, rText
); }
92 virtual void append_text(const OUString
& rText
) override
{ mxControl
->append_text(rText
); }
93 virtual void insert_text(int nPos
, const OUString
& rText
) override
{ mxControl
->insert_text(nPos
, rText
); }
94 virtual void set_active(int nPos
) override
{ mxControl
->set_active(nPos
); }
95 virtual void set_id(int nPos
, const OUString
& rId
) override
{ mxControl
->set_id(nPos
, rId
); }
96 void show() { mxControl
->show(); }
97 void hide() { mxControl
->hide(); }
99 void set_sensitive(bool bSensitive
) { mxControl
->set_sensitive(bSensitive
); }
100 void connect_changed(const Link
<weld::ComboBox
&, void>& rLink
) { mxControl
->connect_changed(rLink
); }
101 OUString
get_buildable_name() const { return mxControl
->get_buildable_name(); }
102 void set_buildable_name(const OUString
& rId
){ mxControl
->set_buildable_name(rId
); }
105 class SW_DLLPUBLIC SwNumFormatTreeView final
: public SwNumFormatBase
107 std::unique_ptr
<weld::TreeView
> mxControl
;
109 DECL_DLLPRIVATE_LINK( SelectHdl
, weld::TreeView
&, void );
111 virtual void Init() override
;
114 SwNumFormatTreeView(std::unique_ptr
<weld::TreeView
> xControl
);
116 virtual sal_uInt32
GetFormat() const override
;
118 virtual void clear() override
;
119 virtual int get_count() const override
{ return mxControl
->n_children(); }
120 virtual int get_active() const override
{ return mxControl
->get_selected_index(); }
121 virtual OUString
get_id(int nPos
) const override
{ return mxControl
->get_id(nPos
); }
122 virtual OUString
get_text(int nPos
) const override
{ return mxControl
->get_text(nPos
); }
123 virtual weld::Widget
& get_widget() const override
{ return *mxControl
; }
124 virtual void append(const OUString
& rId
, const OUString
& rText
) override
{ mxControl
->append(rId
, rText
); }
125 virtual void append_text(const OUString
& rText
) override
{ mxControl
->append_text(rText
); }
126 virtual void insert_text(int nPos
, const OUString
& rText
) override
{ mxControl
->insert_text(nPos
, rText
); }
127 virtual void set_active(int nPos
) override
{ mxControl
->select(nPos
); }
128 virtual void set_id(int nPos
, const OUString
& rId
) override
{ mxControl
->set_id(nPos
, rId
); }
129 OUString
get_selected_text() const { return mxControl
->get_selected_text(); }
130 bool get_visible() const { return mxControl
->get_visible(); }
131 int get_selected_index() const { return mxControl
->get_selected_index(); }
132 void set_visible(bool bVisible
) { mxControl
->set_visible(bVisible
); }
133 void select(int nPos
) { mxControl
->select(nPos
); }
134 void connect_row_activated(const Link
<weld::TreeView
&, bool>& rLink
) { mxControl
->connect_row_activated(rLink
); }
135 OUString
get_buildable_name() const { return mxControl
->get_buildable_name(); }
136 void set_buildable_name(const OUString
& rId
){ mxControl
->set_buildable_name(rId
); }
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */