fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / paragr.cxx
blobb9ebdf55e9549d53d1d98c84df9cde89ffa79770
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 "sdresid.hxx"
34 #include "glob.hrc"
35 #include "sdattr.hrc"
37 class SdParagraphNumTabPage : public SfxTabPage
39 public:
40 SdParagraphNumTabPage(Window* pParent, const SfxItemSet& rSet );
41 ~SdParagraphNumTabPage();
43 static SfxTabPage* Create( Window* pParent, const SfxItemSet& rSet );
44 static sal_uInt16* GetRanges();
46 virtual sal_Bool FillItemSet( SfxItemSet& rSet );
47 virtual void Reset( const SfxItemSet& rSet );
49 private:
50 TriStateBox maNewStartCB;
51 TriStateBox maNewStartNumberCB;
52 NumericField maNewStartNF;
53 bool mbModified;
55 DECL_LINK( ImplNewStartHdl, void* );
58 SdParagraphNumTabPage::SdParagraphNumTabPage(Window* pParent, const SfxItemSet& rAttr )
59 : SfxTabPage(pParent, SdResId(RID_TABPAGE_PARA_NUMBERING), rAttr)
60 , maNewStartCB( this, SdResId( CB_NEW_START ) )
61 , maNewStartNumberCB( this, SdResId( CB_NUMBER_NEW_START ) )
62 , maNewStartNF( this, SdResId( NF_NEW_START ) )
63 , mbModified(false)
65 FreeResource();
67 maNewStartCB.SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
68 maNewStartNumberCB.SetClickHdl(LINK(this, SdParagraphNumTabPage, ImplNewStartHdl));
71 SdParagraphNumTabPage::~SdParagraphNumTabPage()
75 SfxTabPage* SdParagraphNumTabPage::Create(Window *pParent, const SfxItemSet & rAttrSet)
77 return new SdParagraphNumTabPage( pParent, rAttrSet );
80 sal_uInt16* SdParagraphNumTabPage::GetRanges()
82 static sal_uInt16 aRange[] =
84 ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
88 return aRange;
91 sal_Bool SdParagraphNumTabPage::FillItemSet( SfxItemSet& rSet )
93 if(maNewStartCB.GetState() != maNewStartCB.GetSavedValue() ||
94 maNewStartNumberCB.GetState() != maNewStartNumberCB.GetSavedValue()||
95 maNewStartNF.GetText() != maNewStartNF.GetSavedValue())
97 mbModified = true;
98 sal_Bool bNewStartChecked = STATE_CHECK == maNewStartCB.GetState();
99 sal_Bool bNumberNewStartChecked = STATE_CHECK == maNewStartNumberCB.GetState();
100 rSet.Put(SfxBoolItem(ATTR_NUMBER_NEWSTART, bNewStartChecked));
102 const sal_Int16 nStartAt = (sal_Int16)maNewStartNF.GetValue();
103 rSet.Put(SfxInt16Item(ATTR_NUMBER_NEWSTART_AT, bNumberNewStartChecked && bNewStartChecked ? nStartAt : -1));
106 return mbModified;
109 void SdParagraphNumTabPage::Reset( const SfxItemSet& rSet )
111 SfxItemState eItemState = rSet.GetItemState( ATTR_NUMBER_NEWSTART );
112 if(eItemState > SFX_ITEM_AVAILABLE )
114 const SfxBoolItem& rStart = (const SfxBoolItem&)rSet.Get(ATTR_NUMBER_NEWSTART);
115 maNewStartCB.SetState( rStart.GetValue() ? STATE_CHECK : STATE_NOCHECK );
116 maNewStartCB.EnableTriState(sal_False);
118 else
120 maNewStartCB.SetState(STATE_DONTKNOW);
121 maNewStartCB.Disable();
123 maNewStartCB.SaveValue();
125 eItemState = rSet.GetItemState( ATTR_NUMBER_NEWSTART_AT);
126 if( eItemState > SFX_ITEM_AVAILABLE )
128 sal_Int16 nNewStart = ((const SfxInt16Item&)rSet.Get(ATTR_NUMBER_NEWSTART_AT)).GetValue();
129 maNewStartNumberCB.Check(-1 != nNewStart);
130 if(-1 == nNewStart)
131 nNewStart = 1;
133 maNewStartNF.SetValue(nNewStart);
134 maNewStartNumberCB.EnableTriState(sal_False);
136 else
138 maNewStartCB.SetState(STATE_DONTKNOW);
140 ImplNewStartHdl(&maNewStartCB);
141 maNewStartNF.SaveValue();
142 maNewStartNumberCB.SaveValue();
143 mbModified = sal_False;
146 IMPL_LINK_NOARG(SdParagraphNumTabPage, ImplNewStartHdl)
148 sal_Bool bEnable = maNewStartCB.IsChecked();
149 maNewStartNumberCB.Enable(bEnable);
150 maNewStartNF.Enable(bEnable && maNewStartNumberCB.IsChecked());
151 return 0;
154 SdParagraphDlg::SdParagraphDlg( Window* pParent, const SfxItemSet* pAttr )
155 : SfxTabDialog( pParent, SdResId( TAB_PARAGRAPH ), pAttr )
157 FreeResource();
159 AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
161 SvtCJKOptions aCJKOptions;
162 if( aCJKOptions.IsAsianTypographyEnabled() )
163 AddTabPage( RID_SVXPAGE_PARA_ASIAN);
164 else
165 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
167 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
169 static const sal_Bool bShowParaNumbering = ( getenv( "SD_SHOW_NUMBERING_PAGE" ) != NULL );
170 if( bShowParaNumbering )
171 AddTabPage( RID_TABPAGE_PARA_NUMBERING, SdParagraphNumTabPage::Create, SdParagraphNumTabPage::GetRanges );
172 else
173 RemoveTabPage( RID_TABPAGE_PARA_NUMBERING );
175 AddTabPage( RID_SVXPAGE_TABULATOR );
178 void SdParagraphDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
180 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
181 switch( nId )
183 case RID_SVXPAGE_STD_PARAGRAPH:
184 aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/2));
185 rPage.PageCreated(aSet);
186 break;
187 default:
188 break;
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */