LibreOffice Module sd (master) 1
paragr.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#include <svl/cjkoptions.hxx>
21#include <svl/eitem.hxx>
22#include <svl/intitem.hxx>
23
24#include <svx/dialogs.hrc>
25#include <svx/svxids.hrc>
26#include <svx/flagsdef.hxx>
27#include <svx/xcolit.hxx>
28
29#include <paragr.hxx>
30#include <sdattr.hrc>
31
32namespace {
33
34class SdParagraphNumTabPage : public SfxTabPage
35{
36public:
37 SdParagraphNumTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
38 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
39
41
42 virtual bool FillItemSet( SfxItemSet* rSet ) override;
43 virtual void Reset( const SfxItemSet* rSet ) override;
44
45private:
46 bool mbModified;
47 std::unique_ptr<weld::CheckButton> m_xNewStartCB;
48 std::unique_ptr<weld::CheckButton> m_xNewStartNumberCB;
49 std::unique_ptr<weld::SpinButton> m_xNewStartNF;
50
51 DECL_LINK( ImplNewStartHdl, weld::Toggleable&, void );
52};
53
54}
55
56SdParagraphNumTabPage::SdParagraphNumTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
57 : SfxTabPage(pPage, pController, "modules/sdraw/ui/paranumberingtab.ui", "DrawParaNumbering", &rAttr)
58 , mbModified(false)
59 , m_xNewStartCB(m_xBuilder->weld_check_button("checkbuttonCB_NEW_START"))
60 , m_xNewStartNumberCB(m_xBuilder->weld_check_button("checkbuttonCB_NUMBER_NEW_START"))
61 , m_xNewStartNF(m_xBuilder->weld_spin_button("spinbuttonNF_NEW_START"))
62{
63 m_xNewStartCB->connect_toggled(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
64 m_xNewStartNumberCB->connect_toggled(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
65}
66
67std::unique_ptr<SfxTabPage> SdParagraphNumTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet * rAttrSet)
68{
69 return std::make_unique<SdParagraphNumTabPage>(pPage, pController, *rAttrSet);
70}
71
72WhichRangesContainer SdParagraphNumTabPage::GetRanges()
73{
74 return WhichRangesContainer(svl::Items<ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END>);
75}
76
77bool SdParagraphNumTabPage::FillItemSet( SfxItemSet* rSet )
78{
79 if (m_xNewStartCB->get_state_changed_from_saved() ||
80 m_xNewStartNumberCB->get_state_changed_from_saved()||
81 m_xNewStartNF->get_value_changed_from_saved())
82 {
83 mbModified = true;
84 bool bNewStartChecked = TRISTATE_TRUE == m_xNewStartCB->get_state();
85 bool bNumberNewStartChecked = TRISTATE_TRUE == m_xNewStartNumberCB->get_state();
86 rSet->Put(SfxBoolItem(ATTR_NUMBER_NEWSTART, bNewStartChecked));
87
88 const sal_Int16 nStartAt = static_cast<sal_Int16>(m_xNewStartNF->get_value());
89 rSet->Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT, bNumberNewStartChecked && bNewStartChecked ? nStartAt : -1));
90 }
91
92 return mbModified;
93}
94
95void SdParagraphNumTabPage::Reset( const SfxItemSet* rSet )
96{
97 SfxItemState eItemState = rSet->GetItemState( ATTR_NUMBER_NEWSTART );
98 if(eItemState > SfxItemState::DEFAULT )
99 {
100 const SfxBoolItem& rStart = rSet->Get(ATTR_NUMBER_NEWSTART);
101 m_xNewStartCB->set_state( rStart.GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
102 }
103 else
104 {
105 m_xNewStartCB->set_state(TRISTATE_INDET);
106 m_xNewStartCB->set_sensitive(false);
107 }
108 m_xNewStartCB->save_state();
109
110 eItemState = rSet->GetItemState( ATTR_NUMBER_NEWSTART_AT);
111 if( eItemState > SfxItemState::DEFAULT )
112 {
113 sal_Int16 nNewStart = rSet->Get(ATTR_NUMBER_NEWSTART_AT).GetValue();
114 m_xNewStartNumberCB->set_active(-1 != nNewStart);
115 if(-1 == nNewStart)
116 nNewStart = 1;
117
118 m_xNewStartNF->set_value(nNewStart);
119 }
120 else
121 {
122 m_xNewStartCB->set_state(TRISTATE_INDET);
123 }
124 ImplNewStartHdl(*m_xNewStartCB);
125 m_xNewStartNF->save_value();
126 m_xNewStartNumberCB->save_state();
127 mbModified = false;
128}
129
130IMPL_LINK_NOARG(SdParagraphNumTabPage, ImplNewStartHdl, weld::Toggleable&, void)
131{
132 bool bEnable = m_xNewStartCB->get_active();
133 m_xNewStartNumberCB->set_sensitive(bEnable);
134 m_xNewStartNF->set_sensitive(bEnable && m_xNewStartNumberCB->get_active());
135}
136
138 : SfxTabDialogController(pParent, "modules/sdraw/ui/drawparadialog.ui",
139 "DrawParagraphPropertiesDialog", pAttr)
140{
141 AddTabPage( "labelTP_PARA_STD", RID_SVXPAGE_STD_PARAGRAPH);
142
144 AddTabPage( "labelTP_PARA_ASIAN", RID_SVXPAGE_PARA_ASIAN);
145 else
146 RemoveTabPage( "labelTP_PARA_ASIAN" );
147
148 AddTabPage( "labelTP_PARA_ALIGN", RID_SVXPAGE_ALIGN_PARAGRAPH);
149
150 static const bool bShowParaNumbering = ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != nullptr );
151 if( bShowParaNumbering )
152 AddTabPage( "labelNUMBERING", SdParagraphNumTabPage::Create, SdParagraphNumTabPage::GetRanges );
153 else
154 RemoveTabPage( "labelNUMBERING" );
155
156 AddTabPage("labelTP_TABULATOR", RID_SVXPAGE_TABULATOR);
157}
158
159void SdParagraphDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
160{
161 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
162 if (rId == "labelTP_PARA_STD")
163 {
164 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/2));
165 rPage.PageCreated(aSet);
166 }
167}
168
169/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdParagraphDlg(weld::Window *pParent, const SfxItemSet *pAttr)
Definition: paragr.cxx:137
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
Definition: paragr.cxx:159
bool GetValue() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void RemoveTabPage(const OUString &rName)
SfxItemSet * GetInputSetImpl()
virtual void Reset(const SfxItemSet *)
virtual void PageCreated(const SfxAllItemSet &aSet)
virtual bool FillItemSet(SfxItemSet *)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
constexpr tools::Long MM50
TRISTATE_TRUE
bool IsAsianTypographyEnabled()
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor > > &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
IMPL_LINK_NOARG(SdParagraphNumTabPage, ImplNewStartHdl, weld::Toggleable &, void)
Definition: paragr.cxx:130
SfxItemState
static SfxItemSet & rSet
bool mbModified