Line data Source code
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 <vcl/field.hxx>
21 :
22 : #include <svl/cjkoptions.hxx>
23 : #include <svl/eitem.hxx>
24 : #include <svl/intitem.hxx>
25 :
26 : #include <editeng/editdata.hxx>
27 : #include <svx/dialogs.hrc>
28 : #include <editeng/eeitem.hxx>
29 : #include <svx/flagsdef.hxx>
30 :
31 : #include <editeng/outliner.hxx>
32 : #include "paragr.hxx"
33 : #include "sdresid.hxx"
34 : #include "glob.hrc"
35 : #include "sdattr.hrc"
36 :
37 : class SdParagraphNumTabPage : public SfxTabPage
38 : {
39 : public:
40 : SdParagraphNumTabPage(vcl::Window* pParent, const SfxItemSet& rSet );
41 : virtual ~SdParagraphNumTabPage();
42 :
43 : static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rSet );
44 : static const sal_uInt16* GetRanges();
45 :
46 : virtual bool FillItemSet( SfxItemSet* rSet ) SAL_OVERRIDE;
47 : virtual void Reset( const SfxItemSet* rSet ) SAL_OVERRIDE;
48 :
49 : private:
50 : TriStateBox* m_pNewStartCB;
51 : TriStateBox* m_pNewStartNumberCB;
52 : NumericField* m_pNewStartNF;
53 : bool mbModified;
54 :
55 : DECL_LINK( ImplNewStartHdl, void* );
56 : };
57 :
58 0 : SdParagraphNumTabPage::SdParagraphNumTabPage(vcl::Window* pParent, const SfxItemSet& rAttr )
59 : : SfxTabPage(pParent,
60 : "DrawParaNumbering",
61 : "modules/sdraw/ui/paranumberingtab.ui",
62 : &rAttr),
63 0 : mbModified(false)
64 : {
65 0 : get(m_pNewStartCB,"checkbuttonCB_NEW_START");
66 0 : get(m_pNewStartNumberCB,"checkbuttonCB_NUMBER_NEW_START");
67 0 : get(m_pNewStartNF,"spinbuttonNF_NEW_START");
68 :
69 0 : m_pNewStartCB->SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
70 0 : m_pNewStartNumberCB->SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
71 0 : }
72 :
73 0 : SdParagraphNumTabPage::~SdParagraphNumTabPage()
74 : {
75 0 : }
76 :
77 0 : SfxTabPage* SdParagraphNumTabPage::Create(vcl::Window *pParent, const SfxItemSet * rAttrSet)
78 : {
79 0 : return new SdParagraphNumTabPage( pParent, *rAttrSet );
80 : }
81 :
82 0 : const sal_uInt16* SdParagraphNumTabPage::GetRanges()
83 : {
84 : static const sal_uInt16 aRange[] =
85 : {
86 : ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
87 : 0
88 : };
89 :
90 0 : return aRange;
91 : }
92 :
93 0 : bool SdParagraphNumTabPage::FillItemSet( SfxItemSet* rSet )
94 : {
95 0 : if(m_pNewStartCB->IsValueChangedFromSaved() ||
96 0 : m_pNewStartNumberCB->IsValueChangedFromSaved()||
97 0 : m_pNewStartNF->IsValueChangedFromSaved())
98 : {
99 0 : mbModified = true;
100 0 : bool bNewStartChecked = TRISTATE_TRUE == m_pNewStartCB->GetState();
101 0 : bool bNumberNewStartChecked = TRISTATE_TRUE == m_pNewStartNumberCB->GetState();
102 0 : rSet->Put(SfxBoolItem(ATTR_NUMBER_NEWSTART, bNewStartChecked));
103 :
104 0 : const sal_Int16 nStartAt = (sal_Int16)m_pNewStartNF->GetValue();
105 0 : rSet->Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT, bNumberNewStartChecked && bNewStartChecked ? nStartAt : -1));
106 : }
107 :
108 0 : return mbModified;
109 : }
110 :
111 0 : void SdParagraphNumTabPage::Reset( const SfxItemSet* rSet )
112 : {
113 0 : SfxItemState eItemState = rSet->GetItemState( ATTR_NUMBER_NEWSTART );
114 0 : if(eItemState > SfxItemState::DEFAULT )
115 : {
116 0 : const SfxBoolItem& rStart = (const SfxBoolItem&)rSet->Get(ATTR_NUMBER_NEWSTART);
117 0 : m_pNewStartCB->SetState( rStart.GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
118 0 : m_pNewStartCB->EnableTriState(false);
119 : }
120 : else
121 : {
122 0 : m_pNewStartCB->SetState(TRISTATE_INDET);
123 0 : m_pNewStartCB->Disable();
124 : }
125 0 : m_pNewStartCB->SaveValue();
126 :
127 0 : eItemState = rSet->GetItemState( ATTR_NUMBER_NEWSTART_AT);
128 0 : if( eItemState > SfxItemState::DEFAULT )
129 : {
130 0 : sal_Int16 nNewStart = ((const SfxInt16Item&)rSet->Get(ATTR_NUMBER_NEWSTART_AT)).GetValue();
131 0 : m_pNewStartNumberCB->Check(-1 != nNewStart);
132 0 : if(-1 == nNewStart)
133 0 : nNewStart = 1;
134 :
135 0 : m_pNewStartNF->SetValue(nNewStart);
136 0 : m_pNewStartNumberCB->EnableTriState(false);
137 : }
138 : else
139 : {
140 0 : m_pNewStartCB->SetState(TRISTATE_INDET);
141 : }
142 0 : ImplNewStartHdl(m_pNewStartCB);
143 0 : m_pNewStartNF->SaveValue();
144 0 : m_pNewStartNumberCB->SaveValue();
145 0 : mbModified = false;
146 0 : }
147 :
148 0 : IMPL_LINK_NOARG(SdParagraphNumTabPage, ImplNewStartHdl)
149 : {
150 0 : bool bEnable = m_pNewStartCB->IsChecked();
151 0 : m_pNewStartNumberCB->Enable(bEnable);
152 0 : m_pNewStartNF->Enable(bEnable && m_pNewStartNumberCB->IsChecked());
153 0 : return 0;
154 : }
155 :
156 0 : SdParagraphDlg::SdParagraphDlg( vcl::Window* pParent, const SfxItemSet* pAttr )
157 : : SfxTabDialog( pParent,
158 : "DrawParagraphPropertiesDialog",
159 : "modules/sdraw/ui/drawparadialog.ui",
160 0 : pAttr )
161 : {
162 0 : m_nParaStd = AddTabPage( "labelTP_PARA_STD", RID_SVXPAGE_STD_PARAGRAPH);
163 :
164 0 : SvtCJKOptions aCJKOptions;
165 0 : if( aCJKOptions.IsAsianTypographyEnabled() )
166 0 : AddTabPage( "labelTP_PARA_ASIAN", RID_SVXPAGE_PARA_ASIAN);
167 : else
168 0 : RemoveTabPage( "labelTP_PARA_ASIAN" );
169 :
170 0 : AddTabPage( "labelTP_PARA_ALIGN", RID_SVXPAGE_ALIGN_PARAGRAPH);
171 :
172 0 : static const bool bShowParaNumbering = ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != NULL );
173 0 : if( bShowParaNumbering )
174 0 : AddTabPage( "labelNUMBERING", SdParagraphNumTabPage::Create, SdParagraphNumTabPage::GetRanges );
175 : else
176 0 : RemoveTabPage( "labelNUMBERING" );
177 :
178 0 : AddTabPage("labelTP_TABULATOR", RID_SVXPAGE_TABULATOR);
179 0 : }
180 :
181 0 : void SdParagraphDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
182 : {
183 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
184 0 : if (m_nParaStd == nId)
185 : {
186 0 : aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/2));
187 0 : rPage.PageCreated(aSet);
188 0 : }
189 0 : }
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|