1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_cui.hxx" 30 31 // include --------------------------------------------------------------- 32 33 #include "align.hxx" 34 35 #include <editeng/svxenum.hxx> 36 #include <svx/dialogs.hrc> 37 #include <cuires.hrc> 38 #include "align.hrc" 39 #include <svx/rotmodit.hxx> 40 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 55 56 namespace svx { 57 58 // item connections =========================================================== 59 60 // horizontal alignment ------------------------------------------------------- 61 62 typedef sfx::ValueItemWrapper< SvxHorJustifyItem, SvxCellHorJustify, sal_uInt16 > HorJustItemWrapper; 63 typedef sfx::ListBoxConnection< HorJustItemWrapper > HorJustConnection; 64 65 static const HorJustConnection::MapEntryType s_pHorJustMap[] = 66 { 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 } 74 }; 75 76 // vertical alignment --------------------------------------------------------- 77 78 typedef sfx::ValueItemWrapper< SvxVerJustifyItem, SvxCellVerJustify, sal_uInt16 > VerJustItemWrapper; 79 typedef sfx::ListBoxConnection< VerJustItemWrapper > VerJustConnection; 80 81 static const VerJustConnection::MapEntryType s_pVerJustMap[] = 82 { 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 } 88 }; 89 90 // cell rotate mode ----------------------------------------------------------- 91 92 typedef sfx::ValueItemWrapper< SvxRotateModeItem, SvxRotateMode, sal_uInt16 > RotateModeItemWrapper; 93 typedef sfx::ValueSetConnection< RotateModeItemWrapper > RotateModeConnection; 94 95 static const RotateModeConnection::MapEntryType s_pRotateModeMap[] = 96 { 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 } 101 }; 102 103 // ============================================================================ 104 105 static sal_uInt16 s_pRanges[] = 106 { 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, 116 0 117 }; 118 119 // ============================================================================ 120 121 AlignmentTabPage::AlignmentTabPage( Window* pParent, const SfxItemSet& rCoreAttrs ) : 122 123 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_ALIGNMENT ), rCoreAttrs ), 124 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 ) ), 132 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 ), 142 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 ) ) 149 { 150 InitVsRefEgde(); 151 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 ); 158 159 Link aLink = LINK( this, AlignmentTabPage, UpdateEnableHdl ); 160 161 maLbHorAlign.SetSelectHdl( aLink ); 162 maBtnWrap.SetClickHdl( aLink ); 163 164 // Asian vertical mode 165 maCbAsianMode.Show( SvtCJKOptions().IsVerticalTextEnabled() ); 166 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() ) 172 { 173 maFtFrameDir.Hide(); 174 maLbFrameDir.Hide(); 175 } 176 177 // diese Page braucht ExchangeSupport 178 SetExchangeSupport(); 179 180 FreeResource(); 181 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 ) ); 200 201 maLbHorAlign.SetAccessibleRelationMemberOf( &maFlAlignment ); 202 maEdIndent.SetAccessibleRelationMemberOf( &maFlAlignment ); 203 maLbVerAlign.SetAccessibleRelationMemberOf( &maFlAlignment ); 204 } 205 206 AlignmentTabPage::~AlignmentTabPage() 207 { 208 } 209 210 SfxTabPage* AlignmentTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet ) 211 { 212 return new AlignmentTabPage( pParent, rAttrSet ); 213 } 214 215 sal_uInt16* AlignmentTabPage::GetRanges() 216 { 217 return s_pRanges; 218 } 219 220 void AlignmentTabPage::Reset( const SfxItemSet& rCoreAttrs ) 221 { 222 SfxTabPage::Reset( rCoreAttrs ); 223 UpdateEnableControls(); 224 } 225 226 int AlignmentTabPage::DeactivatePage( SfxItemSet* _pSet ) 227 { 228 if( _pSet ) 229 FillItemSet( *_pSet ); 230 return LEAVE_PAGE; 231 } 232 233 void AlignmentTabPage::DataChanged( const DataChangedEvent& rDCEvt ) 234 { 235 SfxTabPage::DataChanged( rDCEvt ); 236 if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 237 { 238 svt::OLocalResourceAccess aLocalResAcc( CUI_RES( RID_SVXPAGE_ALIGNMENT ), RSC_TABPAGE ); 239 InitVsRefEgde(); 240 } 241 } 242 243 void AlignmentTabPage::InitVsRefEgde() 244 { 245 // remember selection - is deleted in call to ValueSet::Clear() 246 sal_uInt16 nSel = maVsRefEdge.GetSelectItemId(); 247 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() ); 251 252 maVsRefEdge.Clear(); 253 maVsRefEdge.SetStyle( maVsRefEdge.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER ); 254 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 ) ) ); 259 260 maVsRefEdge.SetSizePixel( maVsRefEdge.CalcWindowSizePixel( aItemSize ) ); 261 262 maVsRefEdge.SelectItem( nSel ); 263 } 264 265 void AlignmentTabPage::UpdateEnableControls() 266 { 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); 271 272 // indent edit field only for left alignment 273 maFtIndent.Enable( bHorLeft ); 274 maEdIndent.Enable( bHorLeft ); 275 276 // rotation/stacked disabled for fill alignment 277 maOrientHlp.Enable( !bHorFill ); 278 279 // hyphenation only for automatic line breaks or for block alignment 280 maBtnHyphen.Enable( maBtnWrap.IsChecked() || bHorBlock ); 281 282 // shrink only without automatic line break, and not for block and fill 283 maBtnShrink.Enable( (maBtnWrap.GetState() == STATE_NOCHECK) && !bHorBlock && !bHorFill ); 284 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() ); 289 } 290 291 IMPL_LINK( AlignmentTabPage, UpdateEnableHdl, void*, EMPTYARG ) 292 { 293 UpdateEnableControls(); 294 return 0; 295 } 296 297 // ============================================================================ 298 299 } // namespace svx 300 301