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 .
20 #include <vcl/field.hxx>
22 #include <svl/cjkoptions.hxx>
23 #include <svl/eitem.hxx>
24 #include <svl/intitem.hxx>
25 #include <vcl/button.hxx>
27 #include <svx/dialogs.hrc>
28 #include <svx/svxids.hrc>
29 #include <svx/flagsdef.hxx>
34 class SdParagraphNumTabPage
: public SfxTabPage
37 SdParagraphNumTabPage(vcl::Window
* pParent
, const SfxItemSet
& rSet
);
38 virtual ~SdParagraphNumTabPage() override
;
39 virtual void dispose() override
;
41 static VclPtr
<SfxTabPage
> Create( TabPageParent pParent
, const SfxItemSet
* rSet
);
42 static const sal_uInt16
* GetRanges();
44 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
45 virtual void Reset( const SfxItemSet
* rSet
) override
;
48 VclPtr
<TriStateBox
> m_pNewStartCB
;
49 VclPtr
<TriStateBox
> m_pNewStartNumberCB
;
50 VclPtr
<NumericField
> m_pNewStartNF
;
53 DECL_LINK( ImplNewStartHdl
, Button
*, void );
56 SdParagraphNumTabPage::SdParagraphNumTabPage(vcl::Window
* pParent
, const SfxItemSet
& rAttr
)
59 "modules/sdraw/ui/paranumberingtab.ui",
63 get(m_pNewStartCB
,"checkbuttonCB_NEW_START");
64 get(m_pNewStartNumberCB
,"checkbuttonCB_NUMBER_NEW_START");
65 get(m_pNewStartNF
,"spinbuttonNF_NEW_START");
67 m_pNewStartCB
->SetClickHdl(LINK(this, SdParagraphNumTabPage
, ImplNewStartHdl
));
68 m_pNewStartNumberCB
->SetClickHdl(LINK(this, SdParagraphNumTabPage
, ImplNewStartHdl
));
71 SdParagraphNumTabPage::~SdParagraphNumTabPage()
76 void SdParagraphNumTabPage::dispose()
78 m_pNewStartCB
.clear();
79 m_pNewStartNumberCB
.clear();
80 m_pNewStartNF
.clear();
81 SfxTabPage::dispose();
84 VclPtr
<SfxTabPage
> SdParagraphNumTabPage::Create(TabPageParent pParent
, const SfxItemSet
* rAttrSet
)
86 return VclPtr
<SdParagraphNumTabPage
>::Create( pParent
.pParent
, *rAttrSet
);
89 const sal_uInt16
* SdParagraphNumTabPage::GetRanges()
91 static const sal_uInt16 aRange
[] =
93 ATTR_PARANUMBERING_START
, ATTR_PARANUMBERING_END
,
100 bool SdParagraphNumTabPage::FillItemSet( SfxItemSet
* rSet
)
102 if(m_pNewStartCB
->IsValueChangedFromSaved() ||
103 m_pNewStartNumberCB
->IsValueChangedFromSaved()||
104 m_pNewStartNF
->IsValueChangedFromSaved())
107 bool bNewStartChecked
= TRISTATE_TRUE
== m_pNewStartCB
->GetState();
108 bool bNumberNewStartChecked
= TRISTATE_TRUE
== m_pNewStartNumberCB
->GetState();
109 rSet
->Put(SfxBoolItem(ATTR_NUMBER_NEWSTART
, bNewStartChecked
));
111 const sal_Int16 nStartAt
= static_cast<sal_Int16
>(m_pNewStartNF
->GetValue());
112 rSet
->Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT
, bNumberNewStartChecked
&& bNewStartChecked
? nStartAt
: -1));
118 void SdParagraphNumTabPage::Reset( const SfxItemSet
* rSet
)
120 SfxItemState eItemState
= rSet
->GetItemState( ATTR_NUMBER_NEWSTART
);
121 if(eItemState
> SfxItemState::DEFAULT
)
123 const SfxBoolItem
& rStart
= static_cast<const SfxBoolItem
&>(rSet
->Get(ATTR_NUMBER_NEWSTART
));
124 m_pNewStartCB
->SetState( rStart
.GetValue() ? TRISTATE_TRUE
: TRISTATE_FALSE
);
125 m_pNewStartCB
->EnableTriState(false);
129 m_pNewStartCB
->SetState(TRISTATE_INDET
);
130 m_pNewStartCB
->Disable();
132 m_pNewStartCB
->SaveValue();
134 eItemState
= rSet
->GetItemState( ATTR_NUMBER_NEWSTART_AT
);
135 if( eItemState
> SfxItemState::DEFAULT
)
137 sal_Int16 nNewStart
= static_cast<const SfxInt16Item
&>(rSet
->Get(ATTR_NUMBER_NEWSTART_AT
)).GetValue();
138 m_pNewStartNumberCB
->Check(-1 != nNewStart
);
142 m_pNewStartNF
->SetValue(nNewStart
);
143 m_pNewStartNumberCB
->EnableTriState(false);
147 m_pNewStartCB
->SetState(TRISTATE_INDET
);
149 ImplNewStartHdl(m_pNewStartCB
);
150 m_pNewStartNF
->SaveValue();
151 m_pNewStartNumberCB
->SaveValue();
155 IMPL_LINK_NOARG(SdParagraphNumTabPage
, ImplNewStartHdl
, Button
*, void)
157 bool bEnable
= m_pNewStartCB
->IsChecked();
158 m_pNewStartNumberCB
->Enable(bEnable
);
159 m_pNewStartNF
->Enable(bEnable
&& m_pNewStartNumberCB
->IsChecked());
162 SdParagraphDlg::SdParagraphDlg(weld::Window
* pParent
, const SfxItemSet
* pAttr
)
163 : SfxTabDialogController(pParent
, "modules/sdraw/ui/drawparadialog.ui",
164 "DrawParagraphPropertiesDialog", pAttr
)
166 AddTabPage( "labelTP_PARA_STD", RID_SVXPAGE_STD_PARAGRAPH
);
168 SvtCJKOptions aCJKOptions
;
169 if( aCJKOptions
.IsAsianTypographyEnabled() )
170 AddTabPage( "labelTP_PARA_ASIAN", RID_SVXPAGE_PARA_ASIAN
);
172 RemoveTabPage( "labelTP_PARA_ASIAN" );
174 AddTabPage( "labelTP_PARA_ALIGN", RID_SVXPAGE_ALIGN_PARAGRAPH
);
176 static const bool bShowParaNumbering
= ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != nullptr );
177 if( bShowParaNumbering
)
178 AddTabPage( "labelNUMBERING", SdParagraphNumTabPage::Create
, SdParagraphNumTabPage::GetRanges
);
180 RemoveTabPage( "labelNUMBERING" );
182 AddTabPage("labelTP_TABULATOR", RID_SVXPAGE_TABULATOR
);
185 void SdParagraphDlg::PageCreated(const OString
& rId
, SfxTabPage
&rPage
)
187 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
188 if (rId
== "labelTP_PARA_STD")
190 aSet
.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST
, MM50
/2));
191 rPage
.PageCreated(aSet
);
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */