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