Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / controller / dialogs / tp_TitleRotation.cxx
blobd4521676529b252bccc6b5e2d219cfd87434090c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "tp_TitleRotation.hxx"
22 #include "TabPageIds.h"
23 #include <chartview/ChartSfxItemIds.hxx>
25 #include <editeng/eeitem.hxx>
26 #include <editeng/frmdiritem.hxx>
27 #include <svl/intitem.hxx>
29 namespace chart
32 SchAlignmentTabPage::SchAlignmentTabPage(vcl::Window* pWindow,
33 const SfxItemSet& rInAttrs, bool bWithRotation) :
34 SfxTabPage(pWindow, "TitleRotationTabPage","modules/schart/ui/titlerotationtabpage.ui", &rInAttrs)
36 get(m_pCtrlDial,"dialCtrl");
37 get(m_pFtRotate,"degreeL");
38 get(m_pNfRotate,"OrientDegree");
39 get(m_pCbStacked,"stackedCB");
40 get(m_pFtTextDirection,"textdirL");
41 get(m_pLbTextDirection,"textdirLB");
42 get(m_pFtABCD,"labelABCD");
43 m_pCtrlDial->SetText(m_pFtABCD->GetText());
44 m_pOrientHlp = new svx::OrientationHelper(*m_pCtrlDial, *m_pNfRotate, *m_pCbStacked);
46 m_pCbStacked->EnableTriState( false );
47 m_pOrientHlp->Enable();
48 m_pOrientHlp->AddDependentWindow( *m_pFtRotate, TRISTATE_TRUE );
50 if( !bWithRotation )
52 m_pOrientHlp->Hide();
56 SchAlignmentTabPage::~SchAlignmentTabPage()
58 disposeOnce();
61 void SchAlignmentTabPage::dispose()
63 delete m_pOrientHlp;
64 m_pOrientHlp = nullptr;
65 m_pCtrlDial.clear();
66 m_pFtRotate.clear();
67 m_pNfRotate.clear();
68 m_pCbStacked.clear();
69 m_pFtTextDirection.clear();
70 m_pLbTextDirection.clear();
71 m_pFtABCD.clear();
72 SfxTabPage::dispose();
75 VclPtr<SfxTabPage> SchAlignmentTabPage::Create(TabPageParent pParent,
76 const SfxItemSet* rInAttrs)
78 return VclPtr<SchAlignmentTabPage>::Create(pParent.pParent, *rInAttrs);
81 VclPtr<SfxTabPage> SchAlignmentTabPage::CreateWithoutRotation(TabPageParent pParent,
82 const SfxItemSet* rInAttrs)
84 return VclPtr<SchAlignmentTabPage>::Create(pParent.pParent, *rInAttrs, false);
87 bool SchAlignmentTabPage::FillItemSet(SfxItemSet* rOutAttrs)
89 //Since 04/1998 text can be rotated by an arbitrary angle: SCHATTR_TEXT_DEGREES
90 bool bStacked = m_pOrientHlp->GetStackedState() == TRISTATE_TRUE;
91 rOutAttrs->Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
93 sal_Int32 nDegrees = bStacked ? 0 : m_pCtrlDial->GetRotation();
94 rOutAttrs->Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) );
96 SvxFrameDirection aDirection( m_pLbTextDirection->GetSelectEntryValue() );
97 rOutAttrs->Put( SvxFrameDirectionItem( aDirection, EE_PARA_WRITINGDIR ) );
99 return true;
102 void SchAlignmentTabPage::Reset(const SfxItemSet* rInAttrs)
104 const SfxPoolItem* pItem = GetItem( *rInAttrs, SCHATTR_TEXT_DEGREES );
106 sal_Int32 nDegrees = pItem ? static_cast<const SfxInt32Item*>(pItem)->GetValue() : 0;
107 m_pCtrlDial->SetRotation( nDegrees );
109 pItem = GetItem( *rInAttrs, SCHATTR_TEXT_STACKED );
110 bool bStacked = pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue();
111 m_pOrientHlp->SetStackedState( bStacked ? TRISTATE_TRUE : TRISTATE_FALSE );
113 if( rInAttrs->GetItemState(EE_PARA_WRITINGDIR, true, &pItem) == SfxItemState::SET)
114 m_pLbTextDirection->SelectEntryValue( static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue() );
117 } //namespace chart
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */