xref: /trunk/main/sd/source/ui/dlg/morphdlg.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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_sd.hxx"
30 
31 #ifdef SD_DLLIMPLEMENTATION
32 #undef SD_DLLIMPLEMENTATION
33 #endif
34 
35 #include "morphdlg.hxx"
36 
37 #include "strings.hrc"
38 #include "sdresid.hxx"
39 #include "sdmod.hxx"
40 #include "sdiocmpt.hxx"
41 #include "morphdlg.hrc"
42 #include <tools/config.hxx>
43 #include <svx/xfillit0.hxx>
44 #include <svx/xlineit0.hxx>
45 #include <svx/xenum.hxx>
46 #include <svx/svdobj.hxx>
47 #include <svl/itemset.hxx>
48 #include <svl/itempool.hxx>
49 
50 namespace sd {
51 
52 
53 /******************************************************************************/
54 
55 
56 #define FADE_STEP   "FadeSteps"
57 #define FADE_ATTRIB "FadeAttributes"
58 #define FADE_ORIENT "FadeOrientation"
59 #define FADE_TRUE   "true"
60 #define FADE_FALSE  "false"
61 
62 
63 /******************************************************************************/
64 
65 
66 /******************************************************************************
67 |*
68 |*
69 |*
70 \******************************************************************************/
71 
72 MorphDlg::MorphDlg( ::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2 ) :
73             ModalDialog     ( pParent, SdResId( DLG_MORPH ) ),
74             aGrpPreset      ( this, SdResId( GRP_PRESET ) ),
75             aFtSteps        ( this, SdResId( FT_STEPS ) ),
76             aMtfSteps       ( this, SdResId( MTF_STEPS ) ),
77             aCbxAttributes  ( this, SdResId( CBX_ATTRIBUTES ) ),
78             aCbxOrientation ( this, SdResId( CBX_ORIENTATION ) ),
79             aBtnOK          ( this, SdResId( BTN_OK ) ),
80             aBtnCancel      ( this, SdResId( BTN_CANCEL ) ),
81             aBtnHelp        ( this, SdResId( BTN_HELP ) )
82 {
83     FreeResource();
84     LoadSettings();
85 
86     SfxItemPool*    pPool = (SfxItemPool*) pObj1->GetObjectItemPool();
87     SfxItemSet      aSet1( *pPool );
88     SfxItemSet      aSet2( *pPool );
89 
90     aSet1.Put(pObj1->GetMergedItemSet());
91     aSet2.Put(pObj2->GetMergedItemSet());
92 
93     const XLineStyle    eLineStyle1 = ( (const XLineStyleItem&) aSet1.Get( XATTR_LINESTYLE ) ).GetValue();
94     const XLineStyle    eLineStyle2 = ( (const XLineStyleItem&) aSet2.Get( XATTR_LINESTYLE ) ).GetValue();
95     const XFillStyle    eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
96     const XFillStyle    eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
97 
98     if ( ( ( eLineStyle1 == XLINE_NONE ) || ( eLineStyle2 == XLINE_NONE ) ) &&
99          ( ( eFillStyle1 != XFILL_SOLID ) || ( eFillStyle2 != XFILL_SOLID ) ) )
100     {
101         aCbxAttributes.Disable();
102     }
103 }
104 
105 
106 /******************************************************************************
107 |*
108 |*
109 |*
110 \******************************************************************************/
111 
112 MorphDlg::~MorphDlg()
113 {
114 }
115 
116 
117 /******************************************************************************
118 |*
119 |*
120 |*
121 \******************************************************************************/
122 
123 void MorphDlg::LoadSettings()
124 {
125     SvStorageStreamRef  xIStm( SD_MOD()->GetOptionStream( UniString::CreateFromAscii(
126                                RTL_CONSTASCII_STRINGPARAM( SD_OPTION_MORPHING ) ),
127                                SD_OPTION_LOAD ) );
128     sal_uInt16              nSteps;
129     sal_Bool                bOrient, bAttrib;
130 
131     if( xIStm.Is() )
132     {
133         SdIOCompat aCompat( *xIStm, STREAM_READ );
134 
135         *xIStm >> nSteps >> bOrient >> bAttrib;
136     }
137     else
138     {
139         nSteps = 16;
140         bOrient = bAttrib = sal_True;
141     }
142 
143     aMtfSteps.SetValue( nSteps );
144     aCbxOrientation.Check( bOrient );
145     aCbxAttributes.Check( bAttrib );
146 }
147 
148 // -----------------------------------------------------------------------------
149 
150 void MorphDlg::SaveSettings() const
151 {
152     SvStorageStreamRef xOStm( SD_MOD()->GetOptionStream( UniString::CreateFromAscii(
153                                RTL_CONSTASCII_STRINGPARAM( SD_OPTION_MORPHING ) ),
154                                SD_OPTION_STORE ) );
155 
156     if( xOStm.Is() )
157     {
158         SdIOCompat aCompat( *xOStm, STREAM_WRITE, 1 );
159 
160         *xOStm << (sal_uInt16) aMtfSteps.GetValue()
161                << aCbxOrientation.IsChecked()
162                << aCbxAttributes.IsChecked();
163     }
164 }
165 
166 } // end of namespace sd
167