Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / ui / dlg / paragr.cxx
blob3b7aa7698cc6e471ec5efd79fcf7339d12236234
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
26 #include <editeng/editdata.hxx>
27 #include <svx/dialogs.hrc>
28 #include <editeng/eeitem.hxx>
29 #include <svx/flagsdef.hxx>
31 #include <editeng/outliner.hxx>
32 #include <paragr.hxx>
33 #include <sdattr.hrc>
35 class SdParagraphNumTabPage : public SfxTabPage
37 public:
38 SdParagraphNumTabPage(vcl::Window* pParent, const SfxItemSet& rSet );
39 virtual ~SdParagraphNumTabPage() override;
40 virtual void dispose() override;
42 static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rSet );
43 static const sal_uInt16* GetRanges();
45 virtual bool FillItemSet( SfxItemSet* rSet ) override;
46 virtual void Reset( const SfxItemSet* rSet ) override;
48 private:
49 VclPtr<TriStateBox> m_pNewStartCB;
50 VclPtr<TriStateBox> m_pNewStartNumberCB;
51 VclPtr<NumericField> m_pNewStartNF;
52 bool mbModified;
54 DECL_LINK( ImplNewStartHdl, Button*, void );
57 SdParagraphNumTabPage::SdParagraphNumTabPage(vcl::Window* pParent, const SfxItemSet& rAttr )
58 : SfxTabPage(pParent,
59 "DrawParaNumbering",
60 "modules/sdraw/ui/paranumberingtab.ui",
61 &rAttr),
62 mbModified(false)
64 get(m_pNewStartCB,"checkbuttonCB_NEW_START");
65 get(m_pNewStartNumberCB,"checkbuttonCB_NUMBER_NEW_START");
66 get(m_pNewStartNF,"spinbuttonNF_NEW_START");
68 m_pNewStartCB->SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
69 m_pNewStartNumberCB->SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
72 SdParagraphNumTabPage::~SdParagraphNumTabPage()
74 disposeOnce();
77 void SdParagraphNumTabPage::dispose()
79 m_pNewStartCB.clear();
80 m_pNewStartNumberCB.clear();
81 m_pNewStartNF.clear();
82 SfxTabPage::dispose();
85 VclPtr<SfxTabPage> SdParagraphNumTabPage::Create(TabPageParent pParent, const SfxItemSet * rAttrSet)
87 return VclPtr<SdParagraphNumTabPage>::Create( pParent.pParent, *rAttrSet );
90 const sal_uInt16* SdParagraphNumTabPage::GetRanges()
92 static const sal_uInt16 aRange[] =
94 ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
98 return aRange;
101 bool SdParagraphNumTabPage::FillItemSet( SfxItemSet* rSet )
103 if(m_pNewStartCB->IsValueChangedFromSaved() ||
104 m_pNewStartNumberCB->IsValueChangedFromSaved()||
105 m_pNewStartNF->IsValueChangedFromSaved())
107 mbModified = true;
108 bool bNewStartChecked = TRISTATE_TRUE == m_pNewStartCB->GetState();
109 bool bNumberNewStartChecked = TRISTATE_TRUE == m_pNewStartNumberCB->GetState();
110 rSet->Put(SfxBoolItem(ATTR_NUMBER_NEWSTART, bNewStartChecked));
112 const sal_Int16 nStartAt = static_cast<sal_Int16>(m_pNewStartNF->GetValue());
113 rSet->Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT, bNumberNewStartChecked && bNewStartChecked ? nStartAt : -1));
116 return mbModified;
119 void SdParagraphNumTabPage::Reset( const SfxItemSet* rSet )
121 SfxItemState eItemState = rSet->GetItemState( ATTR_NUMBER_NEWSTART );
122 if(eItemState > SfxItemState::DEFAULT )
124 const SfxBoolItem& rStart = static_cast<const SfxBoolItem&>(rSet->Get(ATTR_NUMBER_NEWSTART));
125 m_pNewStartCB->SetState( rStart.GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
126 m_pNewStartCB->EnableTriState(false);
128 else
130 m_pNewStartCB->SetState(TRISTATE_INDET);
131 m_pNewStartCB->Disable();
133 m_pNewStartCB->SaveValue();
135 eItemState = rSet->GetItemState( ATTR_NUMBER_NEWSTART_AT);
136 if( eItemState > SfxItemState::DEFAULT )
138 sal_Int16 nNewStart = static_cast<const SfxInt16Item&>(rSet->Get(ATTR_NUMBER_NEWSTART_AT)).GetValue();
139 m_pNewStartNumberCB->Check(-1 != nNewStart);
140 if(-1 == nNewStart)
141 nNewStart = 1;
143 m_pNewStartNF->SetValue(nNewStart);
144 m_pNewStartNumberCB->EnableTriState(false);
146 else
148 m_pNewStartCB->SetState(TRISTATE_INDET);
150 ImplNewStartHdl(m_pNewStartCB);
151 m_pNewStartNF->SaveValue();
152 m_pNewStartNumberCB->SaveValue();
153 mbModified = false;
156 IMPL_LINK_NOARG(SdParagraphNumTabPage, ImplNewStartHdl, Button*, void)
158 bool bEnable = m_pNewStartCB->IsChecked();
159 m_pNewStartNumberCB->Enable(bEnable);
160 m_pNewStartNF->Enable(bEnable && m_pNewStartNumberCB->IsChecked());
163 SdParagraphDlg::SdParagraphDlg( vcl::Window* pParent, const SfxItemSet* pAttr )
164 : SfxTabDialog( pParent,
165 "DrawParagraphPropertiesDialog",
166 "modules/sdraw/ui/drawparadialog.ui",
167 pAttr )
169 m_nParaStd = AddTabPage( "labelTP_PARA_STD", RID_SVXPAGE_STD_PARAGRAPH);
171 SvtCJKOptions aCJKOptions;
172 if( aCJKOptions.IsAsianTypographyEnabled() )
173 AddTabPage( "labelTP_PARA_ASIAN", RID_SVXPAGE_PARA_ASIAN);
174 else
175 RemoveTabPage( "labelTP_PARA_ASIAN" );
177 AddTabPage( "labelTP_PARA_ALIGN", RID_SVXPAGE_ALIGN_PARAGRAPH);
179 static const bool bShowParaNumbering = ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != nullptr );
180 if( bShowParaNumbering )
181 AddTabPage( "labelNUMBERING", SdParagraphNumTabPage::Create, SdParagraphNumTabPage::GetRanges );
182 else
183 RemoveTabPage( "labelNUMBERING" );
185 AddTabPage("labelTP_TABULATOR", RID_SVXPAGE_TABULATOR);
188 void SdParagraphDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
190 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
191 if (m_nParaStd == nId)
193 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/2));
194 rPage.PageCreated(aSet);
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */