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