Line data Source code
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 "strings.hrc"
23 : #include "sdresid.hxx"
24 : #include "sdmod.hxx"
25 : #include "sdiocmpt.hxx"
26 : #include "morphdlg.hrc"
27 : #include <svx/xfillit0.hxx>
28 : #include <svx/xlineit0.hxx>
29 : #include <svx/xenum.hxx>
30 : #include <svx/svdobj.hxx>
31 : #include <svl/itemset.hxx>
32 : #include <svl/itempool.hxx>
33 :
34 : namespace sd {
35 :
36 0 : MorphDlg::MorphDlg( ::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2 ) :
37 : ModalDialog ( pParent, SdResId( DLG_MORPH ) ),
38 : aGrpPreset ( this, SdResId( GRP_PRESET ) ),
39 : aFtSteps ( this, SdResId( FT_STEPS ) ),
40 : aMtfSteps ( this, SdResId( MTF_STEPS ) ),
41 : aCbxAttributes ( this, SdResId( CBX_ATTRIBUTES ) ),
42 : aCbxOrientation ( this, SdResId( CBX_ORIENTATION ) ),
43 : aBtnOK ( this, SdResId( BTN_OK ) ),
44 : aBtnCancel ( this, SdResId( BTN_CANCEL ) ),
45 0 : aBtnHelp ( this, SdResId( BTN_HELP ) )
46 : {
47 0 : FreeResource();
48 0 : LoadSettings();
49 :
50 0 : SfxItemPool* pPool = (SfxItemPool*) pObj1->GetObjectItemPool();
51 0 : SfxItemSet aSet1( *pPool );
52 0 : SfxItemSet aSet2( *pPool );
53 :
54 0 : aSet1.Put(pObj1->GetMergedItemSet());
55 0 : aSet2.Put(pObj2->GetMergedItemSet());
56 :
57 0 : const XLineStyle eLineStyle1 = ( (const XLineStyleItem&) aSet1.Get( XATTR_LINESTYLE ) ).GetValue();
58 0 : const XLineStyle eLineStyle2 = ( (const XLineStyleItem&) aSet2.Get( XATTR_LINESTYLE ) ).GetValue();
59 0 : const XFillStyle eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
60 0 : const XFillStyle eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
61 :
62 0 : if ( ( ( eLineStyle1 == XLINE_NONE ) || ( eLineStyle2 == XLINE_NONE ) ) &&
63 0 : ( ( eFillStyle1 != XFILL_SOLID ) || ( eFillStyle2 != XFILL_SOLID ) ) )
64 : {
65 0 : aCbxAttributes.Disable();
66 0 : }
67 0 : }
68 :
69 0 : MorphDlg::~MorphDlg()
70 : {
71 0 : }
72 :
73 0 : void MorphDlg::LoadSettings()
74 : {
75 0 : SvStorageStreamRef xIStm( SD_MOD()->GetOptionStream( OUString(SD_OPTION_MORPHING) ,
76 0 : SD_OPTION_LOAD ) );
77 : sal_uInt16 nSteps;
78 : sal_Bool bOrient, bAttrib;
79 :
80 0 : if( xIStm.Is() )
81 : {
82 0 : SdIOCompat aCompat( *xIStm, STREAM_READ );
83 :
84 0 : *xIStm >> nSteps >> bOrient >> bAttrib;
85 : }
86 : else
87 : {
88 0 : nSteps = 16;
89 0 : bOrient = bAttrib = sal_True;
90 : }
91 :
92 0 : aMtfSteps.SetValue( nSteps );
93 0 : aCbxOrientation.Check( bOrient );
94 0 : aCbxAttributes.Check( bAttrib );
95 0 : }
96 :
97 : // -----------------------------------------------------------------------------
98 :
99 0 : void MorphDlg::SaveSettings() const
100 : {
101 0 : SvStorageStreamRef xOStm( SD_MOD()->GetOptionStream( OUString(SD_OPTION_MORPHING) ,
102 0 : SD_OPTION_STORE ) );
103 :
104 0 : if( xOStm.Is() )
105 : {
106 0 : SdIOCompat aCompat( *xOStm, STREAM_WRITE, 1 );
107 :
108 0 : *xOStm << (sal_uInt16) aMtfSteps.GetValue()
109 0 : << aCbxOrientation.IsChecked()
110 0 : << aCbxAttributes.IsChecked();
111 0 : }
112 0 : }
113 :
114 0 : } // end of namespace sd
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|