1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <morphdlg.hxx>
21 
22 #include <sdmod.hxx>
23 #include <sdiocmpt.hxx>
24 #include <svx/xdef.hxx>
25 #include <svx/xfillit0.hxx>
26 #include <svx/xlineit0.hxx>
27 #include <svx/svdobj.hxx>
28 #include <svl/itemset.hxx>
29 #include <com/sun/star/drawing/LineStyle.hpp>
30 
31 using namespace com::sun::star;
32 
33 namespace sd {
34 
MorphDlg(weld::Window * pParent,const SdrObject * pObj1,const SdrObject * pObj2)35 MorphDlg::MorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2 )
36     : GenericDialogController(pParent, "modules/sdraw/ui/crossfadedialog.ui", "CrossFadeDialog")
37     , m_xMtfSteps(m_xBuilder->weld_spin_button("increments"))
38     , m_xCbxAttributes(m_xBuilder->weld_check_button("attributes"))
39     , m_xCbxOrientation(m_xBuilder->weld_check_button("orientation"))
40 {
41     LoadSettings();
42 
43     SfxItemPool &   rPool = pObj1->GetObjectItemPool();
44     SfxItemSet      aSet1( rPool );
45     SfxItemSet      aSet2( rPool );
46 
47     aSet1.Put(pObj1->GetMergedItemSet());
48     aSet2.Put(pObj2->GetMergedItemSet());
49 
50     const drawing::LineStyle eLineStyle1 = aSet1.Get( XATTR_LINESTYLE ).GetValue();
51     const drawing::LineStyle eLineStyle2 = aSet2.Get( XATTR_LINESTYLE ).GetValue();
52     const drawing::FillStyle eFillStyle1 = aSet1.Get( XATTR_FILLSTYLE ).GetValue();
53     const drawing::FillStyle eFillStyle2 = aSet2.Get( XATTR_FILLSTYLE ).GetValue();
54 
55     if ( ( ( eLineStyle1 == drawing::LineStyle_NONE ) || ( eLineStyle2 == drawing::LineStyle_NONE ) ) &&
56          ( ( eFillStyle1 != drawing::FillStyle_SOLID ) || ( eFillStyle2 != drawing::FillStyle_SOLID ) ) )
57     {
58         m_xCbxAttributes->set_sensitive(false);
59     }
60 }
61 
~MorphDlg()62 MorphDlg::~MorphDlg()
63 {
64 }
65 
LoadSettings()66 void MorphDlg::LoadSettings()
67 {
68     tools::SvRef<SotStorageStream>  xIStm( SD_MOD()->GetOptionStream( SD_OPTION_MORPHING ,
69                                SdOptionStreamMode::Load ) );
70     sal_uInt16              nSteps;
71     bool                bOrient, bAttrib;
72 
73     if( xIStm.is() )
74     {
75         SdIOCompat aCompat( *xIStm, StreamMode::READ );
76 
77         xIStm->ReadUInt16( nSteps ).ReadCharAsBool( bOrient ).ReadCharAsBool( bAttrib );
78     }
79     else
80     {
81         nSteps = 16;
82         bOrient = bAttrib = true;
83     }
84 
85     m_xMtfSteps->set_value(nSteps);
86     m_xCbxOrientation->set_active(bOrient);
87     m_xCbxAttributes->set_active(bAttrib);
88 }
89 
SaveSettings() const90 void MorphDlg::SaveSettings() const
91 {
92     tools::SvRef<SotStorageStream> xOStm( SD_MOD()->GetOptionStream( SD_OPTION_MORPHING ,
93                                SdOptionStreamMode::Store ) );
94 
95     if( xOStm.is() )
96     {
97         SdIOCompat aCompat( *xOStm, StreamMode::WRITE, 1 );
98 
99         xOStm->WriteUInt16( m_xMtfSteps->get_value() )
100               .WriteBool( m_xCbxOrientation->get_active() )
101               .WriteBool( m_xCbxAttributes->get_active() );
102     }
103 }
104 
105 } // end of namespace sd
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
108