Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <sfx2/app.hxx>
30 : : #include <sfx2/module.hxx>
31 : : #include <tools/shl.hxx>
32 : : #include <cuires.hrc>
33 : : #include <svx/svddef.hxx>
34 : : #include <svx/sdtditm.hxx>
35 : : #include <svx/sdtagitm.hxx>
36 : : #include <svx/sdtaitm.hxx>
37 : : #include <svx/sdtfsitm.hxx>
38 : : #include <svx/sdtcfitm.hxx>
39 : : #include <svx/svdobj.hxx>
40 : : #include <svx/svdmark.hxx>
41 : : #include <svx/svdview.hxx>
42 : : #include <svx/svdotext.hxx>
43 : : #include <svx/dialogs.hrc>
44 : :
45 : : #ifndef _SVX_TEXTATTR_CXX
46 : : #define _SVX_TEXTATTR_CXX
47 : : #endif
48 : : #include "textattr.hxx"
49 : : #include "textattr.hrc"
50 : : #include <dialmgr.hxx>
51 : : #include "svx/dlgutil.hxx"
52 : : #include <sfx2/request.hxx>
53 : : #include <svx/ofaitem.hxx>
54 : : #include <editeng/writingmodeitem.hxx>
55 : :
56 : : static sal_uInt16 pRanges[] =
57 : : {
58 : : SDRATTR_MISC_FIRST, SDRATTR_TEXT_HORZADJUST,
59 : : SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
60 : : 0
61 : : };
62 : :
63 : : /*************************************************************************
64 : : |*
65 : : |* dialog (page) for copying objects
66 : : |*
67 : : \************************************************************************/
68 : :
69 : 0 : SvxTextAttrPage::SvxTextAttrPage( Window* pWindow, const SfxItemSet& rInAttrs ) :
70 : 0 : SvxTabPage ( pWindow, CUI_RES( RID_SVXPAGE_TEXTATTR ),
71 : : rInAttrs ),
72 : :
73 [ # # ]: 0 : aFlText ( this, CUI_RES( FL_TEXT ) ),
74 [ # # ]: 0 : aTsbAutoGrowWidth ( this, CUI_RES( TSB_AUTOGROW_WIDTH ) ),
75 [ # # ]: 0 : aTsbAutoGrowHeight ( this, CUI_RES( TSB_AUTOGROW_HEIGHT ) ),
76 [ # # ]: 0 : aTsbFitToSize ( this, CUI_RES( TSB_FIT_TO_SIZE ) ),
77 [ # # ]: 0 : aTsbContour ( this, CUI_RES( TSB_CONTOUR ) ),
78 [ # # ]: 0 : aTsbWordWrapText( this, CUI_RES( TSB_WORDWRAP_TEXT ) ),
79 [ # # ]: 0 : aTsbAutoGrowSize( this, CUI_RES( TSB_AUTOGROW_SIZE ) ),
80 [ # # ]: 0 : aFlDistance ( this, CUI_RES( FL_DISTANCE ) ),
81 [ # # ]: 0 : aFtLeft ( this, CUI_RES( FT_LEFT ) ),
82 [ # # ]: 0 : aMtrFldLeft ( this, CUI_RES( MTR_FLD_LEFT ) ),
83 [ # # ]: 0 : aFtRight ( this, CUI_RES( FT_RIGHT ) ),
84 [ # # ]: 0 : aMtrFldRight ( this, CUI_RES( MTR_FLD_RIGHT ) ),
85 [ # # ]: 0 : aFtTop ( this, CUI_RES( FT_TOP ) ),
86 [ # # ]: 0 : aMtrFldTop ( this, CUI_RES( MTR_FLD_TOP ) ),
87 [ # # ]: 0 : aFtBottom ( this, CUI_RES( FT_BOTTOM ) ),
88 [ # # ]: 0 : aMtrFldBottom ( this, CUI_RES( MTR_FLD_BOTTOM ) ),
89 : :
90 [ # # ]: 0 : aFlSeparator ( this, CUI_RES( FL_SEPARATOR ) ),
91 : :
92 [ # # ]: 0 : aFlPosition ( this, CUI_RES( FL_POSITION ) ),
93 [ # # ]: 0 : aCtlPosition ( this, CUI_RES( CTL_POSITION ),
94 : : RP_MM, 240, 100 ),
95 [ # # ]: 0 : aTsbFullWidth ( this, CUI_RES( TSB_FULL_WIDTH ) ),
96 : :
97 [ # # ][ # # ]: 0 : rOutAttrs ( rInAttrs )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
98 : : {
99 [ # # ]: 0 : FreeResource();
100 : :
101 [ # # ]: 0 : FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
102 [ # # ]: 0 : SetFieldUnit( aMtrFldLeft, eFUnit );
103 [ # # ]: 0 : SetFieldUnit( aMtrFldRight, eFUnit );
104 [ # # ]: 0 : SetFieldUnit( aMtrFldTop, eFUnit );
105 [ # # ]: 0 : SetFieldUnit( aMtrFldBottom, eFUnit );
106 : :
107 [ # # ]: 0 : Link aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
108 : 0 : aTsbAutoGrowWidth.SetClickHdl( aLink );
109 : 0 : aTsbAutoGrowHeight.SetClickHdl( aLink );
110 : 0 : aTsbFitToSize.SetClickHdl( aLink );
111 : 0 : aTsbContour.SetClickHdl( aLink );
112 : :
113 : : aTsbFullWidth.SetClickHdl(
114 [ # # ]: 0 : LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
115 : :
116 [ # # ]: 0 : aCtlPosition.SetAccessibleRelationMemberOf( &aFlPosition );
117 : 0 : }
118 : :
119 : : /*************************************************************************
120 : : |*
121 : : |* Dtor
122 : : |*
123 : : \************************************************************************/
124 : :
125 [ # # ][ # # ]: 0 : SvxTextAttrPage::~SvxTextAttrPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
126 : : {
127 [ # # ]: 0 : }
128 : :
129 : : /*************************************************************************
130 : : |*
131 : : |* reads the passed item set
132 : : |*
133 : : \************************************************************************/
134 : :
135 : 0 : void SvxTextAttrPage::Reset( const SfxItemSet& rAttrs )
136 : : {
137 : 0 : SfxItemPool* pPool = rAttrs.GetPool();
138 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
139 : 0 : SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
140 : :
141 : 0 : const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_TEXT_LEFTDIST );
142 : :
143 [ # # ]: 0 : if( !pItem )
144 : 0 : pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
145 [ # # ]: 0 : if( pItem )
146 : : {
147 : 0 : long nValue = ( ( const SdrTextLeftDistItem* )pItem )->GetValue();
148 : 0 : SetMetricValue( aMtrFldLeft, nValue, eUnit );
149 : : }
150 : : else
151 [ # # ]: 0 : aMtrFldLeft.SetText( String() );
152 : 0 : aMtrFldLeft.SaveValue();
153 : :
154 : 0 : pItem = GetItem( rAttrs, SDRATTR_TEXT_RIGHTDIST );
155 [ # # ]: 0 : if( !pItem )
156 : 0 : pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
157 [ # # ]: 0 : if( pItem )
158 : : {
159 : 0 : long nValue = ( ( const SdrTextRightDistItem* )pItem )->GetValue();
160 : 0 : SetMetricValue( aMtrFldRight, nValue, eUnit );
161 : : }
162 : : else
163 [ # # ]: 0 : aMtrFldRight.SetText( String() );
164 : 0 : aMtrFldRight.SaveValue();
165 : :
166 : 0 : pItem = GetItem( rAttrs, SDRATTR_TEXT_UPPERDIST );
167 [ # # ]: 0 : if( !pItem )
168 : 0 : pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
169 [ # # ]: 0 : if( pItem )
170 : : {
171 : 0 : long nValue = ( ( const SdrTextUpperDistItem* )pItem )->GetValue();
172 : 0 : SetMetricValue( aMtrFldTop, nValue, eUnit );
173 : : }
174 : : else
175 [ # # ]: 0 : aMtrFldTop.SetText( String() );
176 : 0 : aMtrFldTop.SaveValue();
177 : :
178 : 0 : pItem = GetItem( rAttrs, SDRATTR_TEXT_LOWERDIST );
179 [ # # ]: 0 : if( !pItem )
180 : 0 : pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
181 [ # # ]: 0 : if( pItem )
182 : : {
183 : 0 : long nValue = ( ( const SdrTextLowerDistItem* )pItem )->GetValue();
184 : 0 : SetMetricValue( aMtrFldBottom, nValue, eUnit );
185 : : }
186 : : else
187 [ # # ]: 0 : aMtrFldBottom.SetText( String() );
188 : 0 : aMtrFldBottom.SaveValue();
189 : :
190 : : // adjust to height
191 [ # # ]: 0 : if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SFX_ITEM_DONTCARE )
192 : : {
193 : 0 : aTsbAutoGrowHeight.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
194 [ # # ]: 0 : GetValue() ? STATE_CHECK : STATE_NOCHECK );
195 : 0 : aTsbAutoGrowHeight.EnableTriState( sal_False );
196 : : }
197 : : else
198 : 0 : aTsbAutoGrowHeight.SetState( STATE_DONTKNOW );
199 : 0 : aTsbAutoGrowHeight.SaveValue();
200 : :
201 : : // adjust to width
202 [ # # ]: 0 : if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SFX_ITEM_DONTCARE )
203 : : {
204 : 0 : aTsbAutoGrowWidth.SetState( ( ( const SdrTextAutoGrowWidthItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWWIDTH ) ).
205 [ # # ]: 0 : GetValue() ? STATE_CHECK : STATE_NOCHECK );
206 : 0 : aTsbAutoGrowWidth.EnableTriState( sal_False );
207 : : }
208 : : else
209 : 0 : aTsbAutoGrowWidth.SetState( STATE_DONTKNOW );
210 : 0 : aTsbAutoGrowWidth.SaveValue();
211 : :
212 : : // autogrowsize
213 [ # # ]: 0 : if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWSIZE ) != SFX_ITEM_DONTCARE )
214 : : {
215 : 0 : aTsbAutoGrowSize.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
216 [ # # ]: 0 : GetValue() ? STATE_CHECK : STATE_NOCHECK );
217 : 0 : aTsbAutoGrowSize.EnableTriState( sal_False );
218 : : }
219 : : else
220 : 0 : aTsbAutoGrowSize.SetState( STATE_DONTKNOW );
221 : 0 : aTsbAutoGrowSize.SaveValue();
222 : :
223 : : // wordwrap text
224 [ # # ]: 0 : if ( rAttrs.GetItemState( SDRATTR_TEXT_WORDWRAP ) != SFX_ITEM_DONTCARE )
225 : : {
226 : 0 : aTsbWordWrapText.SetState( ( ( const SdrTextWordWrapItem& )rAttrs.Get( SDRATTR_TEXT_WORDWRAP ) ).
227 [ # # ]: 0 : GetValue() ? STATE_CHECK : STATE_NOCHECK );
228 : 0 : aTsbWordWrapText.EnableTriState( sal_False );
229 : : }
230 : : else
231 : 0 : aTsbWordWrapText.SetState( STATE_DONTKNOW );
232 : 0 : aTsbWordWrapText.SaveValue();
233 : :
234 : :
235 : : // #103516# Do the setup based on states of hor/ver adjust
236 : : // Setup center field and FullWidth
237 : 0 : SfxItemState eVState = rAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
238 : 0 : SfxItemState eHState = rAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
239 : :
240 [ # # ][ # # ]: 0 : if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
241 : : {
242 : : // VertAdjust and HorAdjust are unequivocal, thus
243 : 0 : SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)rAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
244 : 0 : SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)((const SdrTextHorzAdjustItem&)rAttrs.Get(SDRATTR_TEXT_HORZADJUST)).GetValue();
245 : 0 : RECT_POINT eRP = RP_LB;
246 : :
247 : 0 : aTsbFullWidth.EnableTriState( sal_False );
248 : :
249 : : // Translate item values into local anchor position.
250 [ # # # # ]: 0 : switch (eTVA)
251 : : {
252 : : case SDRTEXTVERTADJUST_TOP:
253 : : {
254 [ # # # # ]: 0 : switch (eTHA)
255 : : {
256 : 0 : case SDRTEXTHORZADJUST_LEFT: eRP = RP_LT; break;
257 : : case SDRTEXTHORZADJUST_BLOCK:
258 : 0 : case SDRTEXTHORZADJUST_CENTER: eRP = RP_MT; break;
259 : 0 : case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RT; break;
260 : : }
261 : 0 : break;
262 : : }
263 : : case SDRTEXTVERTADJUST_BLOCK:
264 : : case SDRTEXTVERTADJUST_CENTER:
265 : : {
266 [ # # # # ]: 0 : switch (eTHA)
267 : : {
268 : 0 : case SDRTEXTHORZADJUST_LEFT: eRP = RP_LM; break;
269 : : case SDRTEXTHORZADJUST_BLOCK:
270 : 0 : case SDRTEXTHORZADJUST_CENTER: eRP = RP_MM; break;
271 : 0 : case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RM; break;
272 : : }
273 : 0 : break;
274 : : }
275 : : case SDRTEXTVERTADJUST_BOTTOM:
276 : : {
277 [ # # # # ]: 0 : switch (eTHA)
278 : : {
279 : 0 : case SDRTEXTHORZADJUST_LEFT: eRP = RP_LB; break;
280 : : case SDRTEXTHORZADJUST_BLOCK:
281 : 0 : case SDRTEXTHORZADJUST_CENTER: eRP = RP_MB; break;
282 : 0 : case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RB; break;
283 : : }
284 : 0 : break;
285 : : }
286 : : default:
287 : 0 : break;
288 : : }
289 : :
290 : : // See if we have to check the "full width" check button.
291 : 0 : sal_Bool bLeftToRight(IsTextDirectionLeftToRight());
292 : :
293 [ # # ][ # # ]: 0 : if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
[ # # ][ # # ]
294 : : {
295 : : // Move anchor to valid position.
296 : 0 : ClickFullWidthHdl_Impl(NULL);
297 : 0 : aTsbFullWidth.SetState(STATE_CHECK);
298 : : }
299 : :
300 : 0 : aCtlPosition.SetActualRP( eRP );
301 : : }
302 : : else
303 : : {
304 : : // VertAdjust or HorAdjust is not unequivocal
305 : 0 : aCtlPosition.Reset();
306 : :
307 : 0 : aCtlPosition.SetState(STATE_DONTKNOW);
308 : 0 : aCtlPosition.DoCompletelyDisable(sal_True);
309 : :
310 : 0 : aTsbFullWidth.SetState(STATE_DONTKNOW);
311 : 0 : aTsbFullWidth.Enable( sal_False );
312 : 0 : aFlPosition.Enable( sal_False );
313 : : }
314 : :
315 : : // adjust to border
316 [ # # ]: 0 : if ( rAttrs.GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SFX_ITEM_DONTCARE )
317 : : {
318 : : SdrFitToSizeType eFTS = (SdrFitToSizeType)
319 : 0 : ( ( const SdrTextFitToSizeTypeItem& )rAttrs.Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue();
320 : 0 : aTsbFitToSize.SetState( eFTS == SDRTEXTFIT_NONE ? STATE_NOCHECK : STATE_CHECK );
321 : 0 : aTsbFitToSize.EnableTriState( sal_False );
322 : : }
323 : : else
324 : 0 : aTsbFitToSize.SetState( STATE_DONTKNOW );
325 : 0 : aTsbFitToSize.SaveValue();
326 : :
327 [ # # ]: 0 : if( rAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SFX_ITEM_DONTCARE )
328 : : {
329 : 0 : sal_Bool bContour = ( ( const SdrTextContourFrameItem& )rAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
330 [ # # ]: 0 : aTsbContour.SetState( bContour ? STATE_CHECK : STATE_NOCHECK );
331 : 0 : aTsbContour.EnableTriState( sal_False );
332 : : }
333 : : else
334 : 0 : aTsbContour.SetState( STATE_DONTKNOW );
335 : 0 : aTsbContour.SaveValue();
336 : :
337 : 0 : ClickHdl_Impl( NULL );
338 : 0 : }
339 : :
340 : : /*************************************************************************
341 : : |*
342 : : |* fills the passed item set with dialog box attributes
343 : : |*
344 : : \************************************************************************/
345 : :
346 : 0 : sal_Bool SvxTextAttrPage::FillItemSet( SfxItemSet& rAttrs)
347 : : {
348 : 0 : SfxItemPool* pPool = rAttrs.GetPool();
349 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
350 : 0 : SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
351 : :
352 : : sal_Int32 nValue;
353 : : TriState eState;
354 : :
355 [ # # ][ # # ]: 0 : if( aMtrFldLeft.GetText() != aMtrFldLeft.GetSavedValue() )
356 : : {
357 : 0 : nValue = GetCoreValue( aMtrFldLeft, eUnit );
358 [ # # ]: 0 : rAttrs.Put( SdrTextLeftDistItem( nValue ) );
359 : : }
360 : :
361 [ # # ][ # # ]: 0 : if( aMtrFldRight.GetText() != aMtrFldRight.GetSavedValue() )
362 : : {
363 : 0 : nValue = GetCoreValue( aMtrFldRight, eUnit );
364 [ # # ]: 0 : rAttrs.Put( SdrTextRightDistItem( nValue ) );
365 : : }
366 : :
367 [ # # ][ # # ]: 0 : if( aMtrFldTop.GetText() != aMtrFldTop.GetSavedValue() )
368 : : {
369 : 0 : nValue = GetCoreValue( aMtrFldTop, eUnit );
370 [ # # ]: 0 : rAttrs.Put( SdrTextUpperDistItem( nValue ) );
371 : : }
372 : :
373 [ # # ][ # # ]: 0 : if( aMtrFldBottom.GetText() != aMtrFldBottom.GetSavedValue() )
374 : : {
375 : 0 : nValue = GetCoreValue( aMtrFldBottom, eUnit );
376 [ # # ]: 0 : rAttrs.Put( SdrTextLowerDistItem( nValue ) );
377 : : }
378 : :
379 : 0 : eState = aTsbAutoGrowHeight.GetState();
380 [ # # ]: 0 : if( eState != aTsbAutoGrowHeight.GetSavedValue() )
381 : : {
382 [ # # ]: 0 : rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
383 : : }
384 : :
385 : 0 : eState = aTsbAutoGrowWidth.GetState();
386 [ # # ]: 0 : if( eState != aTsbAutoGrowWidth.GetSavedValue() )
387 : : {
388 [ # # ]: 0 : rAttrs.Put( SdrTextAutoGrowWidthItem( (sal_Bool) STATE_CHECK == eState ) );
389 : : }
390 : :
391 : 0 : eState = aTsbAutoGrowSize.GetState();
392 [ # # ]: 0 : if( eState != aTsbAutoGrowSize.GetSavedValue() )
393 : : {
394 [ # # ]: 0 : rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
395 : : }
396 : :
397 : 0 : eState = aTsbWordWrapText.GetState();
398 [ # # ]: 0 : if( eState != aTsbWordWrapText.GetSavedValue() )
399 : : {
400 [ # # ]: 0 : rAttrs.Put( SdrTextWordWrapItem( (sal_Bool) STATE_CHECK == eState ) );
401 : : }
402 : :
403 : 0 : eState = aTsbContour.GetState();
404 [ # # ]: 0 : if( eState != aTsbContour.GetSavedValue() )
405 : : {
406 [ # # ]: 0 : rAttrs.Put( SdrTextContourFrameItem( (sal_Bool) STATE_CHECK == eState ) );
407 : : }
408 : :
409 : 0 : eState = aTsbFitToSize.GetState();
410 [ # # ]: 0 : if( eState != aTsbFitToSize.GetSavedValue() )
411 : : {
412 : : SdrFitToSizeType eFTS;
413 [ # # ]: 0 : switch( eState )
414 : : {
415 : : default: ; //prevent warning
416 : : OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
417 : 0 : case STATE_NOCHECK: eFTS = SDRTEXTFIT_NONE; break;
418 : 0 : case STATE_CHECK: eFTS = SDRTEXTFIT_AUTOFIT; break;
419 : : }
420 [ # # ]: 0 : rAttrs.Put( SdrTextFitToSizeTypeItem( eFTS ) );
421 : : }
422 : :
423 : : // centered
424 : 0 : RECT_POINT eRP = aCtlPosition.GetActualRP();
425 : : SdrTextVertAdjust eTVA, eOldTVA;
426 : : SdrTextHorzAdjust eTHA, eOldTHA;
427 : :
428 [ # # # # : 0 : switch( eRP )
# # # #
# ]
429 : : {
430 : : default:
431 : 0 : case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP;
432 : 0 : eTHA = SDRTEXTHORZADJUST_LEFT; break;
433 : 0 : case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER;
434 : 0 : eTHA = SDRTEXTHORZADJUST_LEFT; break;
435 : 0 : case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
436 : 0 : eTHA = SDRTEXTHORZADJUST_LEFT; break;
437 : 0 : case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP;
438 : 0 : eTHA = SDRTEXTHORZADJUST_CENTER; break;
439 : 0 : case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER;
440 : 0 : eTHA = SDRTEXTHORZADJUST_CENTER; break;
441 : 0 : case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
442 : 0 : eTHA = SDRTEXTHORZADJUST_CENTER; break;
443 : 0 : case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP;
444 : 0 : eTHA = SDRTEXTHORZADJUST_RIGHT; break;
445 : 0 : case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER;
446 : 0 : eTHA = SDRTEXTHORZADJUST_RIGHT; break;
447 : 0 : case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
448 : 0 : eTHA = SDRTEXTHORZADJUST_RIGHT; break;
449 : : }
450 : :
451 : : // #103516# Do not change values if adjust controls were disabled.
452 : 0 : sal_Bool bIsDisabled(aCtlPosition.IsCompletelyDisabled());
453 : :
454 [ # # ]: 0 : if(!bIsDisabled)
455 : : {
456 [ # # ]: 0 : if( aTsbFullWidth.GetState() == STATE_CHECK )
457 : : {
458 [ # # ]: 0 : if (IsTextDirectionLeftToRight())
459 : 0 : eTHA = SDRTEXTHORZADJUST_BLOCK;
460 : : else
461 : 0 : eTVA = SDRTEXTVERTADJUST_BLOCK;
462 : : }
463 : :
464 [ # # ]: 0 : if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE )
465 : : {
466 : : eOldTVA = (SdrTextVertAdjust)
467 : 0 : ( ( const SdrTextVertAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue();
468 [ # # ]: 0 : if( eOldTVA != eTVA )
469 [ # # ]: 0 : rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
470 : : }
471 : : else
472 [ # # ]: 0 : rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
473 : :
474 [ # # ]: 0 : if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SFX_ITEM_DONTCARE )
475 : : {
476 : : eOldTHA = (SdrTextHorzAdjust)
477 : 0 : ( ( const SdrTextHorzAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue();
478 [ # # ]: 0 : if( eOldTHA != eTHA )
479 [ # # ]: 0 : rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
480 : : }
481 : : else
482 [ # # ]: 0 : rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
483 : : }
484 : :
485 : 0 : return( sal_True );
486 : : }
487 : :
488 : 0 : void SvxTextAttrPage::Construct()
489 : : {
490 : : DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
491 : :
492 : 0 : bFitToSizeEnabled = bContourEnabled = sal_True;
493 : 0 : bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_False;
494 : :
495 : 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
496 [ # # ]: 0 : if( rMarkList.GetMarkCount() == 1 )
497 : : {
498 : 0 : const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
499 : 0 : SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
500 [ # # ]: 0 : if( pObj->GetObjInventor() == SdrInventor )
501 : : {
502 [ # # # ]: 0 : switch( eKind )
503 : : {
504 : : case OBJ_TEXT :
505 : : case OBJ_TITLETEXT :
506 : : case OBJ_OUTLINETEXT :
507 : : case OBJ_CAPTION :
508 : : {
509 [ # # ]: 0 : if ( ((SdrTextObj*)pObj)->HasText() )
510 : : {
511 : : // contour NOT possible for pure text objects
512 : 0 : bContourEnabled = sal_False;
513 : :
514 : : // adjusting width and height is ONLY possible for pure text objects
515 : 0 : bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_True;
516 : : }
517 : : }
518 : 0 : break;
519 : : case OBJ_CUSTOMSHAPE :
520 : : {
521 : 0 : bFitToSizeEnabled = bContourEnabled = sal_False;
522 : 0 : bAutoGrowSizeEnabled = sal_True;
523 : 0 : bWordWrapTextEnabled = sal_True;
524 : : }
525 : 0 : break;
526 : : default: ;//prevent warning
527 : : }
528 : : }
529 : : }
530 : 0 : aTsbAutoGrowHeight.Enable( bAutoGrowHeightEnabled );
531 : 0 : aTsbAutoGrowWidth.Enable( bAutoGrowWidthEnabled );
532 : 0 : aTsbFitToSize.Enable( bFitToSizeEnabled );
533 : 0 : aTsbContour.Enable( bContourEnabled );
534 : 0 : aTsbAutoGrowSize.Enable( bAutoGrowSizeEnabled );
535 : 0 : aTsbWordWrapText.Enable( bWordWrapTextEnabled );
536 : 0 : }
537 : :
538 : : /*************************************************************************
539 : : |*
540 : : |* creates the page
541 : : |*
542 : : \************************************************************************/
543 : :
544 : 0 : SfxTabPage* SvxTextAttrPage::Create( Window* pWindow,
545 : : const SfxItemSet& rAttrs )
546 : : {
547 [ # # ]: 0 : return( new SvxTextAttrPage( pWindow, rAttrs ) );
548 : : }
549 : :
550 : 0 : sal_uInt16* SvxTextAttrPage::GetRanges()
551 : : {
552 : 0 : return( pRanges );
553 : : }
554 : :
555 : : /** Check whether we have to uncheck the "Full width" check box.
556 : : */
557 : 0 : void SvxTextAttrPage::PointChanged( Window*, RECT_POINT eRP )
558 : : {
559 [ # # ]: 0 : if (aTsbFullWidth.GetState() == STATE_CHECK)
560 : : {
561 : : // Depending on write direction and currently checked anchor we have
562 : : // to uncheck the "full width" button.
563 [ # # ]: 0 : if (IsTextDirectionLeftToRight())
564 [ # # ]: 0 : switch( eRP )
565 : : {
566 : : case RP_LT:
567 : : case RP_LM:
568 : : case RP_LB:
569 : : case RP_RT:
570 : : case RP_RM:
571 : : case RP_RB:
572 : 0 : aTsbFullWidth.SetState( STATE_NOCHECK );
573 : 0 : break;
574 : : default: ;//prevent warning
575 : : }
576 : : else
577 [ # # ]: 0 : switch (eRP)
578 : : {
579 : : case RP_LT:
580 : : case RP_MT:
581 : : case RP_RT:
582 : : case RP_LB:
583 : : case RP_MB:
584 : : case RP_RB:
585 : 0 : aTsbFullWidth.SetState( STATE_NOCHECK );
586 : 0 : break;
587 : : default: ;//prevent warning
588 : : }
589 : : }
590 : 0 : }
591 : :
592 : : /*************************************************************************
593 : : |*
594 : : |* possibly changes the position of the position-control
595 : : |*
596 : : \************************************************************************/
597 : :
598 : : /** When switching the "full width" check button on the text anchor may have
599 : : to be moved to a valid and adjacent position. This position depends on
600 : : the current anchor position and the text writing direction.
601 : : */
602 : 0 : IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl)
603 : : {
604 [ # # ]: 0 : if( aTsbFullWidth.GetState() == STATE_CHECK )
605 : : {
606 [ # # ]: 0 : if (IsTextDirectionLeftToRight())
607 : : {
608 : : // Move text anchor to horizontal middle axis.
609 [ # # # # ]: 0 : switch( aCtlPosition.GetActualRP() )
610 : : {
611 : : case RP_LT:
612 : : case RP_RT:
613 : 0 : aCtlPosition.SetActualRP( RP_MT );
614 : 0 : break;
615 : :
616 : : case RP_LM:
617 : : case RP_RM:
618 : 0 : aCtlPosition.SetActualRP( RP_MM );
619 : 0 : break;
620 : :
621 : : case RP_LB:
622 : : case RP_RB:
623 : 0 : aCtlPosition.SetActualRP( RP_MB );
624 : 0 : break;
625 : : default: ;//prevent warning
626 : : }
627 : : }
628 : : else
629 : : {
630 : : // Move text anchor to vertical middle axis.
631 [ # # # # ]: 0 : switch( aCtlPosition.GetActualRP() )
632 : : {
633 : : case RP_LT:
634 : : case RP_LB:
635 : 0 : aCtlPosition.SetActualRP( RP_LM );
636 : 0 : break;
637 : :
638 : : case RP_MT:
639 : : case RP_MB:
640 : 0 : aCtlPosition.SetActualRP( RP_MM );
641 : 0 : break;
642 : :
643 : : case RP_RT:
644 : : case RP_RB:
645 : 0 : aCtlPosition.SetActualRP( RP_RM );
646 : 0 : break;
647 : : default: ;//prevent warning
648 : : }
649 : : }
650 : : }
651 : 0 : return( 0L );
652 : : }
653 : :
654 : : /*************************************************************************
655 : : |*
656 : : |* enables/disables "size at text" or "adjust to frame"
657 : : |*
658 : : \************************************************************************/
659 : :
660 : 0 : IMPL_LINK_NOARG(SvxTextAttrPage, ClickHdl_Impl)
661 : : {
662 : 0 : sal_Bool bAutoGrowWidth = aTsbAutoGrowWidth.GetState() == STATE_CHECK;
663 : 0 : sal_Bool bAutoGrowHeight = aTsbAutoGrowHeight.GetState() == STATE_CHECK;
664 : 0 : sal_Bool bFitToSize = aTsbFitToSize.GetState() == STATE_CHECK;
665 : 0 : sal_Bool bContour = aTsbContour.GetState() == STATE_CHECK;
666 : :
667 : : aTsbContour.Enable( !bFitToSize &&
668 [ # # ][ # # ]: 0 : !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
[ # # ]
669 [ # # ][ # # ]: 0 : bContourEnabled );
[ # # ]
670 : :
671 : : aTsbAutoGrowWidth.Enable( !bFitToSize &&
672 [ # # ]: 0 : !( bContour && bContourEnabled ) &&
673 [ # # ][ # # ]: 0 : bAutoGrowWidthEnabled );
[ # # ]
674 : :
675 : : aTsbAutoGrowHeight.Enable( !bFitToSize &&
676 [ # # ]: 0 : !( bContour && bContourEnabled ) &&
677 [ # # ][ # # ]: 0 : bAutoGrowHeightEnabled );
[ # # ]
678 : :
679 [ # # ][ # # ]: 0 : aTsbFitToSize.Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
[ # # ]
680 [ # # ]: 0 : !( bContour && bContourEnabled ) &&
681 [ # # ][ # # ]: 0 : bFitToSizeEnabled );
[ # # ]
682 : :
683 : : // #101901# enable/disable metric fields and decorations dependent of contour
684 : 0 : aMtrFldLeft.Enable(!bContour);
685 : 0 : aMtrFldRight.Enable(!bContour);
686 : 0 : aMtrFldTop.Enable(!bContour);
687 : 0 : aMtrFldBottom.Enable(!bContour);
688 : 0 : aFlDistance.Enable(!bContour);
689 : 0 : aFtLeft.Enable(!bContour);
690 : 0 : aFtRight.Enable(!bContour);
691 : 0 : aFtTop.Enable(!bContour);
692 : 0 : aFtBottom.Enable(!bContour);
693 : :
694 [ # # ][ # # ]: 0 : if( bContour && bContourEnabled )
695 : : {
696 : 0 : aMtrFldLeft.SetValue( 0 );
697 : 0 : aMtrFldRight.SetValue( 0 );
698 : 0 : aMtrFldTop.SetValue( 0 );
699 : 0 : aMtrFldBottom.SetValue( 0 );
700 : : }
701 : :
702 : : // #103516# Do the setup based on states of hor/ver adjust
703 : 0 : SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
704 : 0 : SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
705 [ # # ][ # # ]: 0 : sal_Bool bHorAndVer(SFX_ITEM_DONTCARE == eVState || SFX_ITEM_DONTCARE == eHState);
706 : :
707 : : // #83698# enable/disable text anchoring dependent of contour
708 [ # # ][ # # ]: 0 : aCtlPosition.Enable(!bContour && !bHorAndVer);
709 [ # # ][ # # ]: 0 : aTsbFullWidth.Enable(!bContour && !bHorAndVer);
710 [ # # ][ # # ]: 0 : aFlPosition.Enable(!bContour && !bHorAndVer);
711 : :
712 : 0 : return( 0L );
713 : : }
714 : :
715 : :
716 : 0 : bool SvxTextAttrPage::IsTextDirectionLeftToRight (void) const
717 : : {
718 : : // Determine the text writing direction with left to right as default.
719 : 0 : bool bLeftToRightDirection = true;
720 : 0 : SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
721 : :
722 [ # # ]: 0 : if(SFX_ITEM_DONTCARE != eState)
723 : : {
724 : : const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> (
725 : 0 : rOutAttrs.Get (SDRATTR_TEXTDIRECTION));
726 [ # # ]: 0 : if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL)
727 : 0 : bLeftToRightDirection = false;
728 : : }
729 : 0 : return bLeftToRightDirection;
730 : : }
731 : :
732 : 0 : void SvxTextAttrPage::PageCreated(SfxAllItemSet aSet)
733 : : {
734 : 0 : SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,sal_False);
735 : :
736 [ # # ]: 0 : if (pViewItem)
737 : 0 : SetView( static_cast<SdrView *>(pViewItem->GetValue()));
738 : :
739 : 0 : Construct();
740 : 0 : }
741 : :
742 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|