1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "tp_TitleRotation.hxx"
27 
28 #include "ResId.hxx"
29 #include "TabPages.hrc"
30 #include "chartview/ChartSfxItemIds.hxx"
31 #include "HelpIds.hrc"
32 #include <editeng/eeitem.hxx>
33 #include <editeng/frmdiritem.hxx>
34 
35 // header for class SfxInt32Item
36 #include <svl/intitem.hxx>
37 
38 //.............................................................................
39 namespace chart
40 {
41 //.............................................................................
42 
SchAlignmentTabPage(Window * pWindow,const SfxItemSet & rInAttrs,bool bWithRotation)43 SchAlignmentTabPage::SchAlignmentTabPage(Window* pWindow,
44                                          const SfxItemSet& rInAttrs, bool bWithRotation) :
45     SfxTabPage(pWindow, SchResId(TP_ALIGNMENT), rInAttrs),
46     aFlAlign        ( this, SchResId( FL_ALIGN ) ),
47     aCtrlDial       ( this, SchResId( CTR_DIAL ) ),
48     aFtRotate       ( this, SchResId( FT_DEGREES ) ),
49     aNfRotate       ( this, SchResId( NF_ORIENT ) ),
50     aCbStacked      ( this, SchResId( BTN_TXTSTACKED ) ),
51     aOrientHlp      ( aCtrlDial, aNfRotate, aCbStacked ),
52     aFtTextDirection( this, SchResId( FT_TEXTDIR ) ),
53     aLbTextDirection( this, SchResId( LB_TEXTDIR ), &aFtTextDirection )
54 {
55 	FreeResource();
56 
57     aCbStacked.EnableTriState( sal_False );
58     aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK );
59 
60     if( !bWithRotation )
61     {
62         aOrientHlp.Hide();
63         Point aMove( 0, aCtrlDial.GetPosPixel().Y() - aFtTextDirection.GetPosPixel().Y() );
64         aFtTextDirection.SetPosPixel( aFtTextDirection.GetPosPixel() + aMove );
65         aLbTextDirection.SetPosPixel( aLbTextDirection.GetPosPixel() + aMove );
66 
67         aLbTextDirection.SetHelpId( HID_SCH_TEXTDIRECTION_EQUATION );
68     }
69 }
70 
~SchAlignmentTabPage()71 SchAlignmentTabPage::~SchAlignmentTabPage()
72 {
73 }
74 
Create(Window * pParent,const SfxItemSet & rInAttrs)75 SfxTabPage* SchAlignmentTabPage::Create(Window* pParent,
76                                         const SfxItemSet& rInAttrs)
77 {
78     return new SchAlignmentTabPage(pParent, rInAttrs);
79 }
80 
CreateWithoutRotation(Window * pParent,const SfxItemSet & rInAttrs)81 SfxTabPage* SchAlignmentTabPage::CreateWithoutRotation(Window* pParent,
82                                         const SfxItemSet& rInAttrs)
83 {
84     return new SchAlignmentTabPage(pParent, rInAttrs, false);
85 }
86 
FillItemSet(SfxItemSet & rOutAttrs)87 sal_Bool SchAlignmentTabPage::FillItemSet(SfxItemSet& rOutAttrs)
88 {
89 	//Seit 4/1998 koennen Texte frei gedreht werden: SCHATTR_TEXT_DEGREES
90     bool bStacked = aOrientHlp.GetStackedState() == STATE_CHECK;
91     rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
92 
93     sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation();
94     rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
95 
96     SvxFrameDirection aDirection( aLbTextDirection.GetSelectEntryValue() );
97     rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, aDirection ) );
98 
99 	return sal_True;
100 }
101 
Reset(const SfxItemSet & rInAttrs)102 void SchAlignmentTabPage::Reset(const SfxItemSet& rInAttrs)
103 {
104     const SfxPoolItem* pItem = GetItem( rInAttrs, SCHATTR_TEXT_DEGREES );
105 
106     sal_Int32 nDegrees = pItem ? ((const SfxInt32Item*)pItem)->GetValue() : 0;
107     aCtrlDial.SetRotation( nDegrees );
108 
109     pItem = GetItem( rInAttrs, SCHATTR_TEXT_STACKED );
110     bool bStacked = pItem && ((const SfxBoolItem*)pItem)->GetValue();
111     aOrientHlp.SetStackedState( bStacked ? STATE_CHECK : STATE_NOCHECK );
112 
113 
114     if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, sal_True, &pItem) == SFX_ITEM_SET)
115         aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pItem)->GetValue()) );
116 }
117 
118 //.............................................................................
119 } //namespace chart
120 //.............................................................................
121 
122 
123