xref: /AOO41X/main/cui/source/tabpages/tabline.cxx (revision ff0525f24f03981d56b7579b645949f111420994)
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_cui.hxx"
26 
27 // include ---------------------------------------------------------------
28 #include <tools/shl.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <unotools/pathoptions.hxx>
31 #include <sfx2/app.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <svx/dialogs.hrc>
34 
35 #define _SVX_TABLINE_CXX
36 #include <cuires.hrc>
37 #include "tabline.hrc"
38 //#include "dlgname.hrc"
39 
40 #include "cuitabarea.hxx"
41 #include "cuitabline.hxx"
42 #include "dlgname.hxx"
43 #include <dialmgr.hxx>
44 #include <svx/svdmodel.hxx>
45 #include <svx/xtable.hxx>
46 #include "svx/drawitem.hxx"
47 
48 #define DLGWIN this->GetParent()->GetParent()
49 
50 #define BITMAP_WIDTH   32
51 #define BITMAP_HEIGHT  12
52 #define XOUT_WIDTH    150
53 
54 /*************************************************************************
55 |*
56 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
57 |*
58 \************************************************************************/
59 
60 SvxLineTabDialog::SvxLineTabDialog
61 (
62     Window* pParent,
63     const SfxItemSet* pAttr,
64     SdrModel* pModel,
65     const SdrObject* pSdrObj,
66     sal_Bool bHasObj
67 ) :
68 
69     SfxTabDialog    ( pParent, CUI_RES( RID_SVXDLG_LINE ), pAttr ),
70     pDrawModel      ( pModel ),
71     pObj            ( pSdrObj ),
72     rOutAttrs       ( *pAttr ),
73     pColorTab       ( pModel->GetColorTable() ),
74     mpNewColorTab   ( pModel->GetColorTable() ),
75     pDashList       ( pModel->GetDashList() ),
76     pNewDashList    ( pModel->GetDashList() ),
77     pLineEndList    ( pModel->GetLineEndList() ),
78     pNewLineEndList ( pModel->GetLineEndList() ),
79     bObjSelected    ( bHasObj ),
80     nLineEndListState( CT_NONE ),
81     nDashListState( CT_NONE ),
82     mnColorTableState( CT_NONE ),
83     nPageType( 0 ), // wird hier in erster Linie benutzt, um mit FillItemSet
84                    // die richtigen Attribute zu erhalten ( noch Fragen? )
85     nDlgType( 0 ),
86     nPosDashLb( 0 ),
87     nPosLineEndLb( 0 ),
88     mnPos( 0 ),
89     mbAreaTP( sal_False ),
90     mbDeleteColorTable( sal_True )
91 {
92     FreeResource();
93 
94     bool bLineOnly = false;
95     if( pObj && pObj->GetObjInventor() == SdrInventor )
96     {
97         switch( pObj->GetObjIdentifier() )
98         {
99         case OBJ_LINE:
100         case OBJ_PLIN:
101         case OBJ_PATHLINE:
102         case OBJ_FREELINE:
103         case OBJ_MEASURE:
104         case OBJ_EDGE:
105             bLineOnly = true;
106 
107         default:
108             break;
109         }
110 
111     }
112 
113     AddTabPage( RID_SVXPAGE_LINE, SvxLineTabPage::Create, 0);
114     if( bLineOnly )
115         AddTabPage( RID_SVXPAGE_SHADOW, SvxShadowTabPage::Create, 0 );
116     else
117         RemoveTabPage( RID_SVXPAGE_SHADOW );
118 
119     AddTabPage( RID_SVXPAGE_LINE_DEF, SvxLineDefTabPage::Create, 0);
120     AddTabPage( RID_SVXPAGE_LINEEND_DEF, SvxLineEndDefTabPage::Create, 0);
121 //  AddTabPage( RID_SVXPAGE_COLOR, SvxColorTabPage::Create, 0 );
122 
123     SetCurPageId( RID_SVXPAGE_LINE );
124 
125     CancelButton& rBtnCancel = GetCancelButton();
126     rBtnCancel.SetClickHdl( LINK( this, SvxLineTabDialog, CancelHdlImpl ) );
127 //! rBtnCancel.SetText( CUI_RESSTR( RID_SVXSTR_CLOSE ) );
128 }
129 
130 // -----------------------------------------------------------------------
131 
132 SvxLineTabDialog::~SvxLineTabDialog()
133 {
134 }
135 
136 // -----------------------------------------------------------------------
137 
138 void SvxLineTabDialog::SavePalettes()
139 {
140     SfxObjectShell* pShell = SfxObjectShell::Current();
141     if( mpNewColorTab != pDrawModel->GetColorTable() )
142     {
143         if(mbDeleteColorTable)
144             delete pDrawModel->GetColorTable();
145         pDrawModel->SetColorTable( mpNewColorTab );
146         if ( pShell )
147             pShell->PutItem( SvxColorTableItem( mpNewColorTab, SID_COLOR_TABLE ) );
148         pColorTab = pDrawModel->GetColorTable();
149     }
150     if( pNewDashList != pDrawModel->GetDashList() )
151     {
152         delete pDrawModel->GetDashList();
153         pDrawModel->SetDashList( pNewDashList );
154         if ( pShell )
155             pShell->PutItem( SvxDashListItem( pNewDashList, SID_DASH_LIST ) );
156         pDashList = pDrawModel->GetDashList();
157     }
158     if( pNewLineEndList != pDrawModel->GetLineEndList() )
159     {
160         delete pDrawModel->GetLineEndList();
161         pDrawModel->SetLineEndList( pNewLineEndList );
162         if ( pShell )
163             pShell->PutItem( SvxLineEndListItem( pNewLineEndList, SID_LINEEND_LIST ) );
164         pLineEndList = pDrawModel->GetLineEndList();
165     }
166 
167     // Speichern der Tabellen, wenn sie geaendert wurden.
168 
169     const String aPath( SvtPathOptions().GetPalettePath() );
170 
171     if( nDashListState & CT_MODIFIED )
172     {
173         pDashList->SetPath( aPath );
174         pDashList->Save();
175 
176         // ToolBoxControls werden benachrichtigt:
177         if ( pShell )
178             pShell->PutItem( SvxDashListItem( pDashList, SID_DASH_LIST ) );
179     }
180 
181     if( nLineEndListState & CT_MODIFIED )
182     {
183         pLineEndList->SetPath( aPath );
184         pLineEndList->Save();
185 
186         // ToolBoxControls werden benachrichtigt:
187         if ( pShell )
188             pShell->PutItem( SvxLineEndListItem( pLineEndList, SID_LINEEND_LIST ) );
189     }
190 
191     if( mnColorTableState & CT_MODIFIED )
192     {
193         pColorTab->SetPath( aPath );
194         pColorTab->Save();
195 
196         // ToolBoxControls werden benachrichtigt:
197         if ( pShell )
198             pShell->PutItem( SvxColorTableItem( pColorTab, SID_COLOR_TABLE ) );
199     }
200 }
201 
202 // -----------------------------------------------------------------------
203 
204 short SvxLineTabDialog::Ok()
205 {
206     SavePalettes();
207 
208     // Es wird RET_OK zurueckgeliefert, wenn wenigstens eine
209     // TabPage in FillItemSet() sal_True zurueckliefert. Dieses
210     // geschieht z.Z. standardmaessig.
211     return( SfxTabDialog::Ok() );
212 }
213 
214 // -----------------------------------------------------------------------
215 
216 IMPL_LINK_INLINE_START( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG )
217 {
218     SavePalettes();
219 
220     EndDialog( RET_CANCEL );
221     return 0;
222 }
223 IMPL_LINK_INLINE_END( SvxLineTabDialog, CancelHdlImpl, void *, EMPTYARG )
224 
225 // -----------------------------------------------------------------------
226 
227 void SvxLineTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
228 {
229     switch( nId )
230     {
231         case RID_SVXPAGE_LINE:
232             ( (SvxLineTabPage&) rPage ).SetColorTable( pColorTab );
233             ( (SvxLineTabPage&) rPage ).SetDashList( pDashList );
234             ( (SvxLineTabPage&) rPage ).SetLineEndList( pLineEndList );
235             ( (SvxLineTabPage&) rPage ).SetDlgType( nDlgType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetDlgType( &nDlgType );
236             ( (SvxLineTabPage&) rPage ).SetPageType( nPageType );//CHINA001 ( (SvxLineTabPage&) rPage ).SetPageType( &nPageType );
237             ( (SvxLineTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
238             ( (SvxLineTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
239             ( (SvxLineTabPage&) rPage ).SetDashChgd( &nDashListState );
240             ( (SvxLineTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
241             ( (SvxLineTabPage&) rPage ).SetObjSelected( bObjSelected );
242             ( (SvxLineTabPage&) rPage ).Construct();
243             ( (SvxLineTabPage&) rPage ).SetColorChgd( &mnColorTableState );
244             // ActivatePage() wird das erste mal nicht gerufen
245             ( (SvxLineTabPage&) rPage ).ActivatePage( rOutAttrs );
246         break;
247 
248         case RID_SVXPAGE_LINE_DEF:
249             ( (SvxLineDefTabPage&) rPage ).SetDashList( pDashList );
250             ( (SvxLineDefTabPage&) rPage ).SetDlgType( &nDlgType );
251             ( (SvxLineDefTabPage&) rPage ).SetPageType( &nPageType );
252             ( (SvxLineDefTabPage&) rPage ).SetPosDashLb( &nPosDashLb );
253             ( (SvxLineDefTabPage&) rPage ).SetDashChgd( &nDashListState );
254             ( (SvxLineDefTabPage&) rPage ).SetObjSelected( bObjSelected );
255             ( (SvxLineDefTabPage&) rPage ).Construct();
256         break;
257 
258         case RID_SVXPAGE_LINEEND_DEF:
259             ( (SvxLineEndDefTabPage&) rPage ).SetLineEndList( pLineEndList );
260             ( (SvxLineEndDefTabPage&) rPage ).SetPolyObj( pObj );
261             ( (SvxLineEndDefTabPage&) rPage ).SetDlgType( &nDlgType );
262             ( (SvxLineEndDefTabPage&) rPage ).SetPageType( &nPageType );
263             ( (SvxLineEndDefTabPage&) rPage ).SetPosLineEndLb( &nPosLineEndLb );
264             ( (SvxLineEndDefTabPage&) rPage ).SetLineEndChgd( &nLineEndListState );
265             ( (SvxLineEndDefTabPage&) rPage ).SetObjSelected( bObjSelected );
266             ( (SvxLineEndDefTabPage&) rPage ).Construct();
267         break;
268 
269         case RID_SVXPAGE_SHADOW:
270         {
271             ( (SvxShadowTabPage&) rPage ).SetColorTable( pColorTab );
272             ( (SvxShadowTabPage&) rPage ).SetPageType( nPageType );
273             ( (SvxShadowTabPage&) rPage ).SetDlgType( nDlgType );
274             ( (SvxShadowTabPage&) rPage ).SetAreaTP( &mbAreaTP );
275             ( (SvxShadowTabPage&) rPage ).SetColorChgd( &mnColorTableState );
276             ( (SvxShadowTabPage&) rPage ).Construct();
277         }
278         break;
279 /*
280         case RID_SVXPAGE_COLOR:
281             ( (SvxColorTabPage&) rPage ).SetColorTable( pColorTab );
282             ( (SvxColorTabPage&) rPage ).SetPageType( &nPageType );
283             ( (SvxColorTabPage&) rPage ).SetDlgType( &nDlgType );
284             ( (SvxColorTabPage&) rPage ).SetPos( &mnPos );
285             ( (SvxColorTabPage&) rPage ).SetAreaTP( &mbAreaTP );
286             ( (SvxColorTabPage&) rPage ).SetColorChgd( &mnColorTableState );
287             ( (SvxColorTabPage&) rPage ).SetDeleteColorTable( mbDeleteColorTable );
288             ( (SvxColorTabPage&) rPage ).Construct();
289         break;
290 */
291     }
292 }
293 
294 
295