masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / tabpages / align.cxx
blobd50ee7b5752dc0edaf16d6f045c6869040e87e66
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
33 #include "align.hxx"
35 #include <editeng/svxenum.hxx>
36 #include <svx/dialogs.hrc>
37 #include <cuires.hrc>
38 #include "align.hrc"
39 #include <svx/rotmodit.hxx>
41 #include <svx/algitem.hxx>
42 #include <editeng/frmdiritem.hxx>
43 #include <dialmgr.hxx>
44 #include <svx/dlgutil.hxx>
45 #include <tools/shl.hxx>
46 #include <sfx2/app.hxx>
47 #include <sfx2/module.hxx>
48 #include <sfx2/itemconnect.hxx>
49 #include <svl/cjkoptions.hxx>
50 #include <svl/languageoptions.hxx>
51 #include <svtools/localresaccess.hxx>
52 #include <svx/flagsdef.hxx> //CHINA001
53 #include <svl/intitem.hxx> //CHINA001
54 #include <sfx2/request.hxx> //CHINA001
56 namespace svx {
58 // item connections ===========================================================
60 // horizontal alignment -------------------------------------------------------
62 typedef sfx::ValueItemWrapper< SvxHorJustifyItem, SvxCellHorJustify, sal_uInt16 > HorJustItemWrapper;
63 typedef sfx::ListBoxConnection< HorJustItemWrapper > HorJustConnection;
65 static const HorJustConnection::MapEntryType s_pHorJustMap[] =
67 { ALIGNDLG_HORALIGN_STD, SVX_HOR_JUSTIFY_STANDARD },
68 { ALIGNDLG_HORALIGN_LEFT, SVX_HOR_JUSTIFY_LEFT },
69 { ALIGNDLG_HORALIGN_CENTER, SVX_HOR_JUSTIFY_CENTER },
70 { ALIGNDLG_HORALIGN_RIGHT, SVX_HOR_JUSTIFY_RIGHT },
71 { ALIGNDLG_HORALIGN_BLOCK, SVX_HOR_JUSTIFY_BLOCK },
72 { ALIGNDLG_HORALIGN_FILL, SVX_HOR_JUSTIFY_REPEAT },
73 { LISTBOX_ENTRY_NOTFOUND, SVX_HOR_JUSTIFY_STANDARD }
76 // vertical alignment ---------------------------------------------------------
78 typedef sfx::ValueItemWrapper< SvxVerJustifyItem, SvxCellVerJustify, sal_uInt16 > VerJustItemWrapper;
79 typedef sfx::ListBoxConnection< VerJustItemWrapper > VerJustConnection;
81 static const VerJustConnection::MapEntryType s_pVerJustMap[] =
83 { ALIGNDLG_VERALIGN_STD, SVX_VER_JUSTIFY_STANDARD },
84 { ALIGNDLG_VERALIGN_TOP, SVX_VER_JUSTIFY_TOP },
85 { ALIGNDLG_VERALIGN_MID, SVX_VER_JUSTIFY_CENTER },
86 { ALIGNDLG_VERALIGN_BOTTOM, SVX_VER_JUSTIFY_BOTTOM },
87 { LISTBOX_ENTRY_NOTFOUND, SVX_VER_JUSTIFY_STANDARD }
90 // cell rotate mode -----------------------------------------------------------
92 typedef sfx::ValueItemWrapper< SvxRotateModeItem, SvxRotateMode, sal_uInt16 > RotateModeItemWrapper;
93 typedef sfx::ValueSetConnection< RotateModeItemWrapper > RotateModeConnection;
95 static const RotateModeConnection::MapEntryType s_pRotateModeMap[] =
97 { IID_BOTTOMLOCK, SVX_ROTATE_MODE_BOTTOM },
98 { IID_TOPLOCK, SVX_ROTATE_MODE_TOP },
99 { IID_CELLLOCK, SVX_ROTATE_MODE_STANDARD },
100 { VALUESET_ITEM_NOTFOUND, SVX_ROTATE_MODE_STANDARD }
103 // ============================================================================
105 static sal_uInt16 s_pRanges[] =
107 SID_ATTR_ALIGN_HOR_JUSTIFY,SID_ATTR_ALIGN_VER_JUSTIFY,
108 SID_ATTR_ALIGN_STACKED,SID_ATTR_ALIGN_LINEBREAK,
109 SID_ATTR_ALIGN_INDENT,SID_ATTR_ALIGN_INDENT,
110 SID_ATTR_ALIGN_DEGREES,SID_ATTR_ALIGN_DEGREES,
111 SID_ATTR_ALIGN_LOCKPOS,SID_ATTR_ALIGN_LOCKPOS,
112 SID_ATTR_ALIGN_HYPHENATION,SID_ATTR_ALIGN_HYPHENATION,
113 SID_ATTR_ALIGN_ASIANVERTICAL,SID_ATTR_ALIGN_ASIANVERTICAL,
114 SID_ATTR_FRAMEDIRECTION,SID_ATTR_FRAMEDIRECTION,
115 SID_ATTR_ALIGN_SHRINKTOFIT,SID_ATTR_ALIGN_SHRINKTOFIT,
119 // ============================================================================
121 AlignmentTabPage::AlignmentTabPage( Window* pParent, const SfxItemSet& rCoreAttrs ) :
123 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_ALIGNMENT ), rCoreAttrs ),
125 maFlAlignment ( this, CUI_RES( FL_ALIGNMENT ) ),
126 maFtHorAlign ( this, CUI_RES( FT_HORALIGN ) ),
127 maLbHorAlign ( this, CUI_RES( LB_HORALIGN ) ),
128 maFtIndent ( this, CUI_RES( FT_INDENT ) ),
129 maEdIndent ( this, CUI_RES( ED_INDENT ) ),
130 maFtVerAlign ( this, CUI_RES( FT_VERALIGN ) ),
131 maLbVerAlign ( this, CUI_RES( LB_VERALIGN ) ),
133 maFlOrient ( this, CUI_RES( FL_ORIENTATION ) ),
134 maCtrlDial ( this, CUI_RES( CTR_DIAL ) ),
135 maFtRotate ( this, CUI_RES( FT_DEGREES ) ),
136 maNfRotate ( this, CUI_RES( NF_DEGREES ) ),
137 maFtRefEdge ( this, CUI_RES( FT_BORDER_LOCK ) ),
138 maVsRefEdge ( this, CUI_RES( CTR_BORDER_LOCK ) ),
139 maCbStacked ( this, CUI_RES( BTN_TXTSTACKED ) ),
140 maCbAsianMode ( this, CUI_RES( BTN_ASIAN_VERTICAL ) ),
141 maOrientHlp ( maCtrlDial, maNfRotate, maCbStacked ),
143 maFlProperties ( this, CUI_RES( FL_WRAP ) ),
144 maBtnWrap ( this, CUI_RES( BTN_WRAP ) ),
145 maBtnHyphen ( this, CUI_RES( BTN_HYPH ) ),
146 maBtnShrink ( this, CUI_RES( BTN_SHRINK ) ),
147 maFtFrameDir ( this, CUI_RES( FT_TEXTFLOW ) ),
148 maLbFrameDir ( this, CUI_RES( LB_FRAMEDIR ) )
150 InitVsRefEgde();
152 // windows to be disabled, if stacked text is turned ON
153 maOrientHlp.AddDependentWindow( maFtRotate, STATE_CHECK );
154 maOrientHlp.AddDependentWindow( maFtRefEdge, STATE_CHECK );
155 maOrientHlp.AddDependentWindow( maVsRefEdge, STATE_CHECK );
156 // windows to be disabled, if stacked text is turned OFF
157 maOrientHlp.AddDependentWindow( maCbAsianMode, STATE_NOCHECK );
159 Link aLink = LINK( this, AlignmentTabPage, UpdateEnableHdl );
161 maLbHorAlign.SetSelectHdl( aLink );
162 maBtnWrap.SetClickHdl( aLink );
164 // Asian vertical mode
165 maCbAsianMode.Show( SvtCJKOptions().IsVerticalTextEnabled() );
167 // CTL frame direction
168 maLbFrameDir.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_LTR ), FRMDIR_HORI_LEFT_TOP );
169 maLbFrameDir.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_RTL ), FRMDIR_HORI_RIGHT_TOP );
170 maLbFrameDir.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_SUPER ), FRMDIR_ENVIRONMENT );
171 if( !SvtLanguageOptions().IsCTLFontEnabled() )
173 maFtFrameDir.Hide();
174 maLbFrameDir.Hide();
177 // diese Page braucht ExchangeSupport
178 SetExchangeSupport();
180 FreeResource();
182 AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_HOR_JUSTIFY, maFtHorAlign, sfx::ITEMCONN_HIDE_UNKNOWN ) );
183 AddItemConnection( new HorJustConnection( SID_ATTR_ALIGN_HOR_JUSTIFY, maLbHorAlign, s_pHorJustMap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
184 AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_INDENT, maFtIndent, sfx::ITEMCONN_HIDE_UNKNOWN ) );
185 AddItemConnection( new sfx::UInt16MetricConnection( SID_ATTR_ALIGN_INDENT, maEdIndent, FUNIT_TWIP, sfx::ITEMCONN_HIDE_UNKNOWN ) );
186 AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_VER_JUSTIFY, maFtVerAlign, sfx::ITEMCONN_HIDE_UNKNOWN ) );
187 AddItemConnection( new VerJustConnection( SID_ATTR_ALIGN_VER_JUSTIFY, maLbVerAlign, s_pVerJustMap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
188 AddItemConnection( new DialControlConnection( SID_ATTR_ALIGN_DEGREES, maCtrlDial, sfx::ITEMCONN_HIDE_UNKNOWN ) );
189 AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_DEGREES, maFtRotate, sfx::ITEMCONN_HIDE_UNKNOWN ) );
190 AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_LOCKPOS, maFtRefEdge, sfx::ITEMCONN_HIDE_UNKNOWN ) );
191 AddItemConnection( new RotateModeConnection( SID_ATTR_ALIGN_LOCKPOS, maVsRefEdge, s_pRotateModeMap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
192 AddItemConnection( new OrientStackedConnection( SID_ATTR_ALIGN_STACKED, maOrientHlp ) );
193 AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_ALIGN_STACKED, maCbStacked, sfx::ITEMCONN_HIDE_UNKNOWN ) );
194 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_ASIANVERTICAL, maCbAsianMode, sfx::ITEMCONN_HIDE_UNKNOWN ) );
195 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_LINEBREAK, maBtnWrap, sfx::ITEMCONN_HIDE_UNKNOWN ) );
196 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_HYPHENATION, maBtnHyphen, sfx::ITEMCONN_HIDE_UNKNOWN ) );
197 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_ALIGN_SHRINKTOFIT, maBtnShrink, sfx::ITEMCONN_HIDE_UNKNOWN ) );
198 AddItemConnection( new sfx::DummyItemConnection( SID_ATTR_FRAMEDIRECTION, maFtFrameDir, sfx::ITEMCONN_HIDE_UNKNOWN ) );
199 AddItemConnection( new FrameDirListBoxConnection( SID_ATTR_FRAMEDIRECTION, maLbFrameDir, sfx::ITEMCONN_HIDE_UNKNOWN ) );
201 maLbHorAlign.SetAccessibleRelationMemberOf( &maFlAlignment );
202 maEdIndent.SetAccessibleRelationMemberOf( &maFlAlignment );
203 maLbVerAlign.SetAccessibleRelationMemberOf( &maFlAlignment );
206 AlignmentTabPage::~AlignmentTabPage()
210 SfxTabPage* AlignmentTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
212 return new AlignmentTabPage( pParent, rAttrSet );
215 sal_uInt16* AlignmentTabPage::GetRanges()
217 return s_pRanges;
220 void AlignmentTabPage::Reset( const SfxItemSet& rCoreAttrs )
222 SfxTabPage::Reset( rCoreAttrs );
223 UpdateEnableControls();
226 int AlignmentTabPage::DeactivatePage( SfxItemSet* _pSet )
228 if( _pSet )
229 FillItemSet( *_pSet );
230 return LEAVE_PAGE;
233 void AlignmentTabPage::DataChanged( const DataChangedEvent& rDCEvt )
235 SfxTabPage::DataChanged( rDCEvt );
236 if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
238 svt::OLocalResourceAccess aLocalResAcc( CUI_RES( RID_SVXPAGE_ALIGNMENT ), RSC_TABPAGE );
239 InitVsRefEgde();
243 void AlignmentTabPage::InitVsRefEgde()
245 // remember selection - is deleted in call to ValueSet::Clear()
246 sal_uInt16 nSel = maVsRefEdge.GetSelectItemId();
248 ResId aResId( GetSettings().GetStyleSettings().GetHighContrastMode() ? IL_LOCK_BMPS_HC : IL_LOCK_BMPS, CUI_MGR() );
249 ImageList aImageList( aResId );
250 Size aItemSize( aImageList.GetImage( IID_BOTTOMLOCK ).GetSizePixel() );
252 maVsRefEdge.Clear();
253 maVsRefEdge.SetStyle( maVsRefEdge.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
255 maVsRefEdge.SetColCount( 3 );
256 maVsRefEdge.InsertItem( IID_BOTTOMLOCK, aImageList.GetImage( IID_BOTTOMLOCK ), String( CUI_RES( STR_BOTTOMLOCK ) ) );
257 maVsRefEdge.InsertItem( IID_TOPLOCK, aImageList.GetImage( IID_TOPLOCK ), String( CUI_RES( STR_TOPLOCK ) ) );
258 maVsRefEdge.InsertItem( IID_CELLLOCK, aImageList.GetImage( IID_CELLLOCK ), String( CUI_RES( STR_CELLLOCK ) ) );
260 maVsRefEdge.SetSizePixel( maVsRefEdge.CalcWindowSizePixel( aItemSize ) );
262 maVsRefEdge.SelectItem( nSel );
265 void AlignmentTabPage::UpdateEnableControls()
267 sal_uInt16 nHorAlign = maLbHorAlign.GetSelectEntryPos();
268 bool bHorLeft = (nHorAlign == ALIGNDLG_HORALIGN_LEFT);
269 bool bHorBlock = (nHorAlign == ALIGNDLG_HORALIGN_BLOCK);
270 bool bHorFill = (nHorAlign == ALIGNDLG_HORALIGN_FILL);
272 // indent edit field only for left alignment
273 maFtIndent.Enable( bHorLeft );
274 maEdIndent.Enable( bHorLeft );
276 // rotation/stacked disabled for fill alignment
277 maOrientHlp.Enable( !bHorFill );
279 // hyphenation only for automatic line breaks or for block alignment
280 maBtnHyphen.Enable( maBtnWrap.IsChecked() || bHorBlock );
282 // shrink only without automatic line break, and not for block and fill
283 maBtnShrink.Enable( (maBtnWrap.GetState() == STATE_NOCHECK) && !bHorBlock && !bHorFill );
285 // visibility of fixed lines
286 maFlAlignment.Show( maLbHorAlign.IsVisible() || maEdIndent.IsVisible() || maLbVerAlign.IsVisible() );
287 maFlOrient.Show( maCtrlDial.IsVisible() || maVsRefEdge.IsVisible() || maCbStacked.IsVisible() || maCbAsianMode.IsVisible() );
288 maFlProperties.Show( maBtnWrap.IsVisible() || maBtnHyphen.IsVisible() || maBtnShrink.IsVisible() || maLbFrameDir.IsVisible() );
291 IMPL_LINK( AlignmentTabPage, UpdateEnableHdl, void*, EMPTYARG )
293 UpdateEnableControls();
294 return 0;
297 // ============================================================================
299 } // namespace svx