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_chart2.hxx"
30 #include "tp_TitleRotation.hxx"
31 
32 #include "ResId.hxx"
33 #include "TabPages.hrc"
34 #include "chartview/ChartSfxItemIds.hxx"
35 #include "HelpIds.hrc"
36 #include <editeng/eeitem.hxx>
37 #include <editeng/frmdiritem.hxx>
38 
39 // header for class SfxInt32Item
40 #include <svl/intitem.hxx>
41 
42 //.............................................................................
43 namespace chart
44 {
45 //.............................................................................
46 
47 SchAlignmentTabPage::SchAlignmentTabPage(Window* pWindow,
48                                          const SfxItemSet& rInAttrs, bool bWithRotation) :
49     SfxTabPage(pWindow, SchResId(TP_ALIGNMENT), rInAttrs),
50     aFlAlign        ( this, SchResId( FL_ALIGN ) ),
51     aCtrlDial       ( this, SchResId( CTR_DIAL ) ),
52     aFtRotate       ( this, SchResId( FT_DEGREES ) ),
53     aNfRotate       ( this, SchResId( NF_ORIENT ) ),
54     aCbStacked      ( this, SchResId( BTN_TXTSTACKED ) ),
55     aOrientHlp      ( aCtrlDial, aNfRotate, aCbStacked ),
56     aFtTextDirection( this, SchResId( FT_TEXTDIR ) ),
57     aLbTextDirection( this, SchResId( LB_TEXTDIR ), &aFtTextDirection )
58 {
59 	FreeResource();
60 
61     aCbStacked.EnableTriState( sal_False );
62     aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK );
63 
64     if( !bWithRotation )
65     {
66         aOrientHlp.Hide();
67         Point aMove( 0, aCtrlDial.GetPosPixel().Y() - aFtTextDirection.GetPosPixel().Y() );
68         aFtTextDirection.SetPosPixel( aFtTextDirection.GetPosPixel() + aMove );
69         aLbTextDirection.SetPosPixel( aLbTextDirection.GetPosPixel() + aMove );
70 
71         aLbTextDirection.SetHelpId( HID_SCH_TEXTDIRECTION_EQUATION );
72     }
73 }
74 
75 SchAlignmentTabPage::~SchAlignmentTabPage()
76 {
77 }
78 
79 SfxTabPage* SchAlignmentTabPage::Create(Window* pParent,
80                                         const SfxItemSet& rInAttrs)
81 {
82     return new SchAlignmentTabPage(pParent, rInAttrs);
83 }
84 
85 SfxTabPage* SchAlignmentTabPage::CreateWithoutRotation(Window* pParent,
86                                         const SfxItemSet& rInAttrs)
87 {
88     return new SchAlignmentTabPage(pParent, rInAttrs, false);
89 }
90 
91 sal_Bool SchAlignmentTabPage::FillItemSet(SfxItemSet& rOutAttrs)
92 {
93 	//Seit 4/1998 koennen Texte frei gedreht werden: SCHATTR_TEXT_DEGREES
94     bool bStacked = aOrientHlp.GetStackedState() == STATE_CHECK;
95     rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
96 
97     sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation();
98     rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
99 
100     SvxFrameDirection aDirection( aLbTextDirection.GetSelectEntryValue() );
101     rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, aDirection ) );
102 
103 	return sal_True;
104 }
105 
106 void SchAlignmentTabPage::Reset(const SfxItemSet& rInAttrs)
107 {
108     const SfxPoolItem* pItem = GetItem( rInAttrs, SCHATTR_TEXT_DEGREES );
109 
110     sal_Int32 nDegrees = pItem ? ((const SfxInt32Item*)pItem)->GetValue() : 0;
111     aCtrlDial.SetRotation( nDegrees );
112 
113     pItem = GetItem( rInAttrs, SCHATTR_TEXT_STACKED );
114     bool bStacked = pItem && ((const SfxBoolItem*)pItem)->GetValue();
115     aOrientHlp.SetStackedState( bStacked ? STATE_CHECK : STATE_NOCHECK );
116 
117 
118     if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, sal_True, &pItem) == SFX_ITEM_SET)
119         aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pItem)->GetValue()) );
120 }
121 
122 //.............................................................................
123 } //namespace chart
124 //.............................................................................
125 
126 
127