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 <editeng/sizeitem.hxx>
21 : #include <tools/shl.hxx>
22 : #include <tools/urlobj.hxx>
23 : #include <sfx2/app.hxx>
24 : #include <sfx2/module.hxx>
25 :
26 : #include <cuires.hrc>
27 : #include "svx/xattr.hxx"
28 : #include <svx/xpool.hxx>
29 : #include <svx/xtable.hxx>
30 : #include "svx/drawitem.hxx"
31 : #include "cuitabline.hxx"
32 : #include "dlgname.hxx"
33 : #include <dialmgr.hxx>
34 : #include "svx/dlgutil.hxx"
35 : #include "svx/svxgrahicitem.hxx"
36 : #include <sfx2/request.hxx>
37 : #include <sfx2/dialoghelper.hxx>
38 : #include "svx/ofaitem.hxx"
39 : #include <svx/svdobj.hxx>
40 : #include <svx/svdview.hxx>
41 : #include <svx/svdmodel.hxx>
42 : #include <svx/numvset.hxx>
43 : #include <vcl/msgbox.hxx>
44 : #include <editeng/numitem.hxx>
45 : #include <editeng/svxenum.hxx>
46 : #include <sfx2/objsh.hxx>
47 : #include <editeng/brushitem.hxx>
48 : #include <svx/gallery.hxx>
49 : #include <unotools/localfilehelper.hxx>
50 : #include "paragrph.hrc"
51 : #include "sfx2/opengrf.hxx"
52 : #include <svx/dialmgr.hxx>
53 : #include <svx/dialogs.hrc>
54 : #include <vcl/settings.hxx>
55 :
56 : #define MAX_BMP_WIDTH 16
57 : #define MAX_BMP_HEIGHT 16
58 :
59 : #define MN_GALLERY 4
60 : #define MN_SYMBOLS 5
61 : #define MN_SYMBOLS_NONE 1
62 : #define MN_SYMBOLS_AUTO 2
63 : #define MN_GALLERY_ENTRY 100
64 :
65 :
66 : // static ----------------------------------------------------------------
67 :
68 : static sal_uInt16 pLineRanges[] =
69 : {
70 : XATTR_LINETRANSPARENCE,
71 : XATTR_LINETRANSPARENCE,
72 : SID_ATTR_LINE_STYLE,
73 : SID_ATTR_LINE_ENDCENTER,
74 : 0
75 : };
76 :
77 0 : SvxLineTabPage::SvxLineTabPage
78 : (
79 : Window* pParent,
80 : const SfxItemSet& rInAttrs
81 : ) :
82 : SvxTabPage ( pParent
83 : ,"LineTabPage"
84 : ,"cui/ui/linetabpage.ui"
85 : , rInAttrs ),
86 :
87 : pSymbolList(NULL),
88 : bNewSize(false),
89 : nNumMenuGalleryItems(0),
90 : nSymbolType(SVX_SYMBOLTYPE_UNKNOWN), // unknown respectively unchanged
91 : pSymbolAttr(NULL),
92 :
93 : bLastWidthModified(sal_False),
94 : aSymbolLastSize(Size(0,0)),
95 : bSymbols(sal_False),
96 :
97 : rOutAttrs ( rInAttrs ),
98 : bObjSelected( sal_False ),
99 :
100 0 : pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
101 : aXLStyle ( XLINE_DASH ),
102 : aXWidth ( 1 ),
103 : aXDash ( OUString(), XDash( XDASH_RECT, 3, 7, 2, 40, 15 ) ),
104 : aXColor ( OUString(), COL_LIGHTRED ),
105 : aXLineAttr ( pXPool ),
106 0 : rXLSet ( aXLineAttr.GetItemSet() ),
107 : pnLineEndListState( 0 ),
108 : pnDashListState( 0 ),
109 : pnColorListState( 0 ),
110 0 : nPageType ( 0 )
111 : {
112 0 : get(m_pLbLineStyle,"LB_LINE_STYLE");
113 0 : get(m_pBoxColor,"boxCOLOR");
114 0 : get(m_pLbColor,"LB_COLOR");
115 0 : get(m_pBoxWidth,"boxWIDTH");
116 0 : get(m_pMtrLineWidth,"MTR_FLD_LINE_WIDTH");
117 0 : get(m_pBoxTransparency,"boxTRANSPARENCY");
118 0 : get(m_pMtrTransparent,"MTR_LINE_TRANSPARENT");
119 :
120 0 : get(m_pFlLineEnds,"FL_LINE_ENDS");
121 0 : get(m_pBoxArrowStyles,"boxARROW_STYLES");
122 0 : get(m_pLbStartStyle,"LB_START_STYLE");
123 0 : get(m_pBoxStart,"boxSTART");
124 0 : get(m_pMtrStartWidth,"MTR_FLD_START_WIDTH");
125 0 : get(m_pTsbCenterStart,"TSB_CENTER_START");
126 0 : get(m_pBoxEnd,"boxEND");
127 0 : get(m_pLbEndStyle,"LB_END_STYLE");
128 0 : get(m_pMtrEndWidth,"MTR_FLD_END_WIDTH");
129 0 : get(m_pTsbCenterEnd,"TSB_CENTER_END");
130 0 : get(m_pCbxSynchronize,"CBX_SYNCHRONIZE");
131 0 : get(m_pCtlPreview,"CTL_PREVIEW");
132 :
133 0 : get(m_pGridEdgeCaps,"gridEDGE_CAPS");
134 0 : get(m_pFLEdgeStyle,"FL_EDGE_STYLE");
135 0 : get(m_pLBEdgeStyle,"LB_EDGE_STYLE");
136 : // LineCaps
137 0 : get(m_pLBCapStyle,"LB_CAP_STYLE");
138 :
139 : //#58425# Symbols on a line (e.g. StarChart)
140 0 : get(m_pFlSymbol,"FL_SYMBOL_FORMAT");
141 0 : get(m_pGridIconSize,"gridICON_SIZE");
142 0 : get(m_pSymbolMB,"MB_SYMBOL_BITMAP");
143 0 : get(m_pSymbolWidthMF,"MF_SYMBOL_WIDTH");
144 0 : get(m_pSymbolHeightMF,"MF_SYMBOL_HEIGHT");
145 0 : get(m_pSymbolRatioCB,"CB_SYMBOL_RATIO");
146 :
147 : // This Page requires ExchangeSupport
148 0 : SetExchangeSupport();
149 :
150 : // Metric set
151 0 : FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
152 :
153 0 : switch ( eFUnit )
154 : {
155 : case FUNIT_M:
156 : case FUNIT_KM:
157 0 : eFUnit = FUNIT_MM;
158 : // no break -> we now have mm
159 : case FUNIT_MM:
160 0 : m_pMtrLineWidth->SetSpinSize( 50 );
161 0 : m_pMtrStartWidth->SetSpinSize( 50 );
162 0 : m_pMtrEndWidth->SetSpinSize( 50 );
163 0 : break;
164 :
165 : case FUNIT_INCH:
166 0 : m_pMtrLineWidth->SetSpinSize( 2 );
167 0 : m_pMtrStartWidth->SetSpinSize( 2 );
168 0 : m_pMtrEndWidth->SetSpinSize( 2 );
169 0 : break;
170 : default: ;// prevent warning
171 : }
172 0 : SetFieldUnit( *m_pMtrLineWidth, eFUnit );
173 0 : SetFieldUnit( *m_pMtrStartWidth, eFUnit );
174 0 : SetFieldUnit( *m_pMtrEndWidth, eFUnit );
175 :
176 : // determine PoolUnit
177 0 : SfxItemPool* pPool = rOutAttrs.GetPool();
178 : DBG_ASSERT( pPool, "Where is the pool?" );
179 0 : ePoolUnit = pPool->GetMetric( SID_ATTR_LINE_WIDTH );
180 :
181 0 : m_pLbLineStyle->SetSelectHdl( LINK( this, SvxLineTabPage, ClickInvisibleHdl_Impl ) );
182 0 : m_pLbColor->SetSelectHdl( LINK( this, SvxLineTabPage, ChangePreviewHdl_Impl ) );
183 0 : m_pMtrLineWidth->SetModifyHdl( LINK( this, SvxLineTabPage, ChangePreviewHdl_Impl ) );
184 0 : m_pMtrTransparent->SetModifyHdl( LINK( this, SvxLineTabPage, ChangeTransparentHdl_Impl ) );
185 :
186 0 : Link aStart = LINK( this, SvxLineTabPage, ChangeStartHdl_Impl );
187 0 : Link aEnd = LINK( this, SvxLineTabPage, ChangeEndHdl_Impl );
188 0 : m_pLbStartStyle->SetSelectHdl( aStart );
189 0 : m_pLbEndStyle->SetSelectHdl( aEnd );
190 0 : m_pMtrStartWidth->SetModifyHdl( aStart );
191 0 : m_pMtrEndWidth->SetModifyHdl( aEnd );
192 0 : m_pTsbCenterStart->SetClickHdl( aStart );
193 0 : m_pTsbCenterEnd->SetClickHdl( aEnd );
194 :
195 : // #116827#
196 0 : Link aEdgeStyle = LINK( this, SvxLineTabPage, ChangeEdgeStyleHdl_Impl );
197 0 : m_pLBEdgeStyle->SetSelectHdl( aEdgeStyle );
198 :
199 : // LineCaps
200 0 : Link aCapStyle = LINK( this, SvxLineTabPage, ChangeCapStyleHdl_Impl );
201 0 : m_pLBCapStyle->SetSelectHdl( aCapStyle );
202 :
203 : // Symbols on a line (eg star charts), MB-handler set
204 0 : m_pSymbolMB->SetSelectHdl(LINK(this, SvxLineTabPage, GraphicHdl_Impl));
205 0 : m_pSymbolMB->SetActivateHdl(LINK(this, SvxLineTabPage, MenuCreateHdl_Impl));
206 0 : m_pSymbolWidthMF->SetModifyHdl(LINK(this, SvxLineTabPage, SizeHdl_Impl));
207 0 : m_pSymbolHeightMF->SetModifyHdl(LINK(this, SvxLineTabPage, SizeHdl_Impl));
208 0 : m_pSymbolRatioCB->SetClickHdl(LINK(this, SvxLineTabPage, RatioHdl_Impl));
209 :
210 0 : m_pSymbolRatioCB->Check(true);
211 0 : ShowSymbolControls(sal_False);
212 :
213 0 : nActLineWidth = -1;
214 0 : }
215 :
216 0 : void SvxLineTabPage::ShowSymbolControls(sal_Bool bOn)
217 : {
218 : // Symbols on a line (e.g. StarCharts), symbol-enable controls
219 :
220 0 : bSymbols=bOn;
221 0 : m_pFlSymbol->Show(bOn);
222 0 : m_pCtlPreview->ShowSymbol(bOn);
223 0 : }
224 :
225 0 : SvxLineTabPage::~SvxLineTabPage()
226 : {
227 : // Symbols on a line (e.g. StarCharts), dtor new!
228 :
229 0 : delete m_pSymbolMB->GetPopupMenu()->GetPopupMenu( MN_GALLERY );
230 :
231 0 : if(pSymbolList)
232 0 : delete m_pSymbolMB->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS );
233 :
234 0 : for ( size_t i = 0, n = aGrfBrushItems.size(); i < n; ++i )
235 : {
236 0 : SvxBmpItemInfo* pInfo = aGrfBrushItems[ i ];
237 0 : delete pInfo->pBrushItem;
238 0 : delete pInfo;
239 : }
240 0 : }
241 0 : void SvxLineTabPage::Construct()
242 : {
243 : // Color chart
244 0 : m_pLbColor->Fill( pColorList );
245 0 : FillListboxes();
246 0 : }
247 :
248 0 : void SvxLineTabPage::InitSymbols(MenuButton* pButton)
249 : {
250 : // Initialize popup
251 0 : if(!pButton->GetPopupMenu()->GetPopupMenu( MN_GALLERY ))
252 : {
253 : // Get gallery entries
254 0 : GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
255 :
256 0 : PopupMenu* pPopup = new PopupMenu;
257 0 : OUString aEmptyStr;
258 0 : const OUString *pUIName = NULL;
259 0 : sal_uInt32 i = 0;
260 0 : nNumMenuGalleryItems = aGrfNames.size();
261 0 : for(std::vector<OUString>::iterator it = aGrfNames.begin(); it != aGrfNames.end(); ++it, ++i)
262 : {
263 0 : pUIName = &(*it);
264 :
265 : // Convert URL encodings to UI characters (e.g. %20 for spaces)
266 0 : OUString aPhysicalName;
267 0 : if (utl::LocalFileHelper::ConvertURLToPhysicalName(*it, aPhysicalName))
268 : {
269 0 : pUIName = &aPhysicalName;
270 : }
271 :
272 0 : SvxBrushItem* pBrushItem = new SvxBrushItem(*it, aEmptyStr, GPOS_AREA, SID_ATTR_BRUSH);
273 0 : pBrushItem->SetDoneLink(STATIC_LINK(this, SvxLineTabPage, GraphicArrivedHdl_Impl));
274 :
275 0 : SvxBmpItemInfo* pInfo = new SvxBmpItemInfo();
276 0 : pInfo->pBrushItem = pBrushItem;
277 0 : pInfo->nItemId = (sal_uInt16)(MN_GALLERY_ENTRY + i);
278 0 : if ( i < aGrfBrushItems.size() )
279 : {
280 0 : aGrfBrushItems.insert( aGrfBrushItems.begin() + i, pInfo );
281 : } else
282 : {
283 0 : aGrfBrushItems.push_back( pInfo );
284 : }
285 0 : const Graphic* pGraphic = pBrushItem->GetGraphic();
286 :
287 0 : if(pGraphic)
288 : {
289 0 : Bitmap aBitmap(pGraphic->GetBitmap());
290 0 : Size aSize(aBitmap.GetSizePixel());
291 0 : if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT)
292 : {
293 0 : sal_Bool bWidth = aSize.Width() > aSize.Height();
294 : double nScale = bWidth ?
295 0 : (double)MAX_BMP_WIDTH / (double)aSize.Width():
296 0 : (double)MAX_BMP_HEIGHT / (double)aSize.Height();
297 0 : aBitmap.Scale(nScale, nScale);
298 :
299 : }
300 0 : Image aImage(aBitmap);
301 0 : pPopup->InsertItem(pInfo->nItemId, *pUIName, aImage );
302 : }
303 : else
304 : {
305 0 : Image aImage;
306 0 : pPopup->InsertItem(pInfo->nItemId, *pUIName, aImage );
307 : }
308 0 : }
309 0 : m_pSymbolMB->GetPopupMenu()->SetPopupMenu( MN_GALLERY, pPopup );
310 :
311 0 : if(aGrfNames.empty())
312 0 : m_pSymbolMB->GetPopupMenu()->EnableItem(MN_GALLERY, false);
313 : }
314 :
315 0 : if(!pButton->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS ) && pSymbolList)
316 : {
317 0 : VirtualDevice aVDev;
318 0 : aVDev.SetMapMode(MapMode(MAP_100TH_MM));
319 0 : SdrModel* pModel = new SdrModel;
320 0 : pModel->GetItemPool().FreezeIdRanges();
321 : // Page
322 0 : SdrPage* pPage = new SdrPage( *pModel, false );
323 0 : pPage->SetSize(Size(1000,1000));
324 0 : pModel->InsertPage( pPage, 0 );
325 : // 3D View
326 0 : SdrView* pView = new SdrView( pModel, &aVDev );
327 0 : pView->hideMarkHandles();
328 0 : pView->ShowSdrPage(pPage);
329 :
330 0 : PopupMenu* pPopup = new PopupMenu;
331 0 : OUString aEmptyStr;
332 :
333 : // Generate invisible square to give all symbols a
334 : // bitmap size, which is independent from specific glyph
335 0 : SdrObject *pInvisibleSquare=pSymbolList->GetObj(0);
336 0 : pInvisibleSquare=pInvisibleSquare->Clone();
337 0 : pPage->NbcInsertObject(pInvisibleSquare);
338 0 : pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100));
339 0 : pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100));
340 :
341 0 : for(long i=0;; ++i)
342 : {
343 0 : SdrObject *pObj=pSymbolList->GetObj(i);
344 0 : if(pObj==NULL)
345 0 : break;
346 0 : pObj=pObj->Clone();
347 0 : aGrfNames.push_back(aEmptyStr);
348 0 : pPage->NbcInsertObject(pObj);
349 0 : if(pSymbolAttr)
350 : {
351 0 : pObj->SetMergedItemSet(*pSymbolAttr);
352 : }
353 : else
354 : {
355 0 : pObj->SetMergedItemSet(rOutAttrs);
356 : }
357 0 : pView->MarkAll();
358 0 : BitmapEx aBitmapEx(pView->GetMarkedObjBitmapEx());
359 0 : GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
360 0 : pView->UnmarkAll();
361 0 : pObj=pPage->RemoveObject(1);
362 0 : SdrObject::Free(pObj);
363 :
364 0 : SvxBrushItem* pBrushItem = new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH);
365 0 : pBrushItem->SetDoneLink(STATIC_LINK(this, SvxLineTabPage, GraphicArrivedHdl_Impl));
366 :
367 0 : SvxBmpItemInfo* pInfo = new SvxBmpItemInfo();
368 0 : pInfo->pBrushItem = pBrushItem;
369 0 : pInfo->nItemId = (sal_uInt16)(MN_GALLERY_ENTRY + i + nNumMenuGalleryItems);
370 0 : if ( (size_t)(nNumMenuGalleryItems + i) < aGrfBrushItems.size() ) {
371 0 : aGrfBrushItems.insert( aGrfBrushItems.begin() + nNumMenuGalleryItems + i, pInfo );
372 : } else {
373 0 : aGrfBrushItems.push_back( pInfo );
374 : }
375 :
376 0 : Size aSize(aBitmapEx.GetSizePixel());
377 0 : if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT)
378 : {
379 0 : sal_Bool bWidth = aSize.Width() > aSize.Height();
380 : double nScale = bWidth ?
381 0 : (double)MAX_BMP_WIDTH / (double)aSize.Width():
382 0 : (double)MAX_BMP_HEIGHT / (double)aSize.Height();
383 0 : aBitmapEx.Scale(nScale, nScale);
384 : }
385 0 : Image aImage(aBitmapEx);
386 0 : pPopup->InsertItem(pInfo->nItemId,aEmptyStr,aImage);
387 0 : }
388 0 : pInvisibleSquare=pPage->RemoveObject(0);
389 0 : SdrObject::Free(pInvisibleSquare);
390 :
391 0 : m_pSymbolMB->GetPopupMenu()->SetPopupMenu( MN_SYMBOLS, pPopup );
392 :
393 0 : if(aGrfNames.empty())
394 0 : m_pSymbolMB->GetPopupMenu()->EnableItem(MN_SYMBOLS, false);
395 :
396 0 : delete pView;
397 0 : delete pModel;
398 : }
399 0 : }
400 :
401 0 : void SvxLineTabPage::SymbolSelected(MenuButton* pButton)
402 : {
403 0 : sal_uInt16 nItemId = pButton->GetCurItemId();
404 0 : const Graphic* pGraphic = 0;
405 0 : Graphic aGraphic;
406 0 : bool bResetSize = false;
407 0 : bool bEnable = true;
408 0 : long nPreviousSymbolType = nSymbolType;
409 :
410 0 : if(nItemId >= MN_GALLERY_ENTRY)
411 : {
412 0 : if( (nItemId-MN_GALLERY_ENTRY) >= nNumMenuGalleryItems)
413 : {
414 0 : nSymbolType=nItemId-MN_GALLERY_ENTRY-nNumMenuGalleryItems; // List's index
415 : }
416 : else
417 : {
418 0 : nSymbolType=SVX_SYMBOLTYPE_BRUSHITEM;
419 0 : bResetSize = true;
420 : }
421 0 : SvxBmpItemInfo* pInfo = aGrfBrushItems[ nItemId - MN_GALLERY_ENTRY ];
422 0 : pGraphic = pInfo->pBrushItem->GetGraphic();
423 : }
424 0 : else switch(nItemId)
425 : {
426 : case MN_SYMBOLS_AUTO:
427 : {
428 0 : pGraphic=&aAutoSymbolGraphic;
429 0 : aAutoSymbolGraphic.SetPrefSize( Size(253,253) );
430 0 : nSymbolType=SVX_SYMBOLTYPE_AUTO;
431 : }
432 0 : break;
433 :
434 : case MN_SYMBOLS_NONE:
435 : {
436 0 : nSymbolType=SVX_SYMBOLTYPE_NONE;
437 0 : pGraphic=NULL;
438 0 : bEnable = false;
439 : }
440 0 : break;
441 : default:
442 : {
443 0 : SvxOpenGraphicDialog aGrfDlg(CUI_RES(RID_SVXSTR_EDIT_GRAPHIC));
444 0 : aGrfDlg.EnableLink(false);
445 0 : aGrfDlg.AsLink(false);
446 0 : if( !aGrfDlg.Execute() )
447 : {
448 : // Remember selected filters
449 0 : if( !aGrfDlg.GetGraphic(aGraphic) )
450 : {
451 0 : nSymbolType=SVX_SYMBOLTYPE_BRUSHITEM;
452 0 : pGraphic = &aGraphic;
453 0 : bResetSize = true;
454 : }
455 : }
456 0 : if( !pGraphic )
457 0 : return;
458 : }
459 0 : break;
460 : }
461 :
462 0 : if(pGraphic)
463 : {
464 0 : Size aSize = SvxNumberFormat::GetGraphicSizeMM100(pGraphic);
465 0 : aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)ePoolUnit);
466 0 : aSymbolGraphic=*pGraphic;
467 0 : if( bResetSize )
468 : {
469 0 : aSymbolSize=aSize;
470 : }
471 0 : else if( nPreviousSymbolType == SVX_SYMBOLTYPE_BRUSHITEM )
472 : { //#i31097# Data Point Symbol size changes when a different symbol is choosen(maoyg)
473 0 : if( aSymbolSize.Width() != aSymbolSize.Height() )
474 : {
475 0 : aSize.setWidth( (long)( aSymbolSize.Width() + aSymbolSize.Height() )/2 );
476 0 : aSize.setHeight( (long)( aSymbolSize.Width() + aSymbolSize.Height() )/2 );
477 0 : aSymbolSize = aSize;
478 : }
479 : }
480 0 : m_pCtlPreview->SetSymbol(&aSymbolGraphic,aSymbolSize);
481 : }
482 : else
483 : {
484 0 : aSymbolGraphic=Graphic();
485 0 : m_pCtlPreview->SetSymbol(NULL,aSymbolSize);
486 0 : bEnable = false;
487 : }
488 0 : aSymbolLastSize=aSymbolSize;
489 0 : SetMetricValue(*m_pSymbolWidthMF, aSymbolSize.Width(), ePoolUnit);
490 0 : SetMetricValue(*m_pSymbolHeightMF, aSymbolSize.Height(), ePoolUnit);
491 :
492 0 : m_pGridIconSize->Enable(bEnable);
493 0 : m_pCtlPreview->Invalidate();
494 : }
495 :
496 0 : void SvxLineTabPage::FillListboxes()
497 : {
498 : // Line styles
499 0 : sal_Int32 nOldSelect = m_pLbLineStyle->GetSelectEntryPos();
500 : // aLbLineStyle.FillStyles();
501 0 : m_pLbLineStyle->Fill( pDashList );
502 0 : m_pLbLineStyle->SelectEntryPos( nOldSelect );
503 :
504 : // Line end style
505 0 : OUString sNone( SVX_RES( RID_SVXSTR_NONE ) );
506 0 : nOldSelect = m_pLbStartStyle->GetSelectEntryPos();
507 0 : m_pLbStartStyle->Clear();
508 0 : m_pLbStartStyle->InsertEntry( sNone );
509 0 : m_pLbStartStyle->Fill( pLineEndList );
510 0 : m_pLbStartStyle->SelectEntryPos( nOldSelect );
511 0 : nOldSelect = m_pLbEndStyle->GetSelectEntryPos();
512 0 : m_pLbEndStyle->Clear();
513 0 : m_pLbEndStyle->InsertEntry( sNone );
514 0 : m_pLbEndStyle->Fill( pLineEndList, false );
515 0 : m_pLbEndStyle->SelectEntryPos( nOldSelect );
516 0 : }
517 :
518 :
519 :
520 0 : void SvxLineTabPage::ActivatePage( const SfxItemSet& rSet )
521 : {
522 0 : SFX_ITEMSET_ARG (&rSet,pPageTypeItem,CntUInt16Item,SID_PAGE_TYPE,false);
523 0 : if (pPageTypeItem)
524 0 : SetPageType(pPageTypeItem->GetValue());
525 0 : if( nDlgType == 0 && pDashList.is() )
526 : {
527 : sal_Int32 nPos;
528 : sal_Int32 nCount;
529 :
530 : // Dash list
531 0 : if( ( *pnDashListState & CT_MODIFIED ) ||
532 0 : ( *pnDashListState & CT_CHANGED ) )
533 : {
534 0 : if( *pnDashListState & CT_CHANGED )
535 0 : pDashList = ( (SvxLineTabDialog*) GetParentDialog() )->GetNewDashList();
536 :
537 0 : *pnDashListState = CT_NONE;
538 :
539 : // Style list
540 0 : nPos = m_pLbLineStyle->GetSelectEntryPos();
541 :
542 0 : m_pLbLineStyle->Clear();
543 0 : m_pLbLineStyle->InsertEntry( SVX_RESSTR( RID_SVXSTR_INVISIBLE ) );
544 0 : m_pLbLineStyle->InsertEntry( SVX_RESSTR( RID_SVXSTR_SOLID ) );
545 0 : m_pLbLineStyle->Fill( pDashList );
546 0 : nCount = m_pLbLineStyle->GetEntryCount();
547 :
548 0 : if ( nCount == 0 )
549 : ; // This case should never occur
550 0 : else if( nCount <= nPos )
551 0 : m_pLbLineStyle->SelectEntryPos( 0 );
552 : else
553 0 : m_pLbLineStyle->SelectEntryPos( nPos );
554 : // SelectStyleHdl_Impl( this );
555 : }
556 :
557 0 : INetURLObject aDashURL( pDashList->GetPath() );
558 :
559 0 : aDashURL.Append( pDashList->GetName() );
560 : DBG_ASSERT( aDashURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
561 : // LineEnd list
562 0 : if( ( *pnLineEndListState & CT_MODIFIED ) || ( *pnLineEndListState & CT_CHANGED ) )
563 : {
564 0 : if( *pnLineEndListState & CT_CHANGED )
565 0 : pLineEndList = ( (SvxLineTabDialog*) GetParentDialog() )->GetNewLineEndList();
566 :
567 0 : *pnLineEndListState = CT_NONE;
568 :
569 0 : nPos = m_pLbLineStyle->GetSelectEntryPos();
570 0 : OUString sNone( SVX_RES( RID_SVXSTR_NONE ) );
571 0 : m_pLbStartStyle->Clear();
572 0 : m_pLbStartStyle->InsertEntry( sNone );
573 :
574 0 : m_pLbStartStyle->Fill( pLineEndList );
575 0 : nCount = m_pLbStartStyle->GetEntryCount();
576 0 : if( nCount == 0 )
577 : ; // This case should never occur
578 0 : else if( nCount <= nPos )
579 0 : m_pLbStartStyle->SelectEntryPos( 0 );
580 : else
581 0 : m_pLbStartStyle->SelectEntryPos( nPos );
582 :
583 0 : m_pLbEndStyle->Clear();
584 0 : m_pLbEndStyle->InsertEntry( sNone );
585 :
586 0 : m_pLbEndStyle->Fill( pLineEndList, false );
587 0 : nCount = m_pLbEndStyle->GetEntryCount();
588 :
589 0 : if( nCount == 0 )
590 : ; // This case should never occur
591 0 : else if( nCount <= nPos )
592 0 : m_pLbEndStyle->SelectEntryPos( 0 );
593 : else
594 0 : m_pLbEndStyle->SelectEntryPos( nPos );
595 : }
596 0 : INetURLObject aLineURL( pLineEndList->GetPath() );
597 :
598 0 : aLineURL.Append( pLineEndList->GetName() );
599 : DBG_ASSERT( aLineURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
600 : // Evaluate if another TabPage set another fill type
601 0 : if( m_pLbLineStyle->GetSelectEntryPos() != 0 )
602 : {
603 0 : if( nPageType == 2 ) // 1
604 : {
605 0 : m_pLbLineStyle->SelectEntryPos( *pPosDashLb + 2 ); // +2 due to SOLID and INVLISIBLE
606 0 : ChangePreviewHdl_Impl( this );
607 : }
608 0 : if( nPageType == 3 )
609 : {
610 0 : m_pLbStartStyle->SelectEntryPos( *pPosLineEndLb + 1 );// +1 due to SOLID
611 0 : m_pLbEndStyle->SelectEntryPos( *pPosLineEndLb + 1 );// +1 due to SOLID
612 0 : ChangePreviewHdl_Impl( this );
613 : }
614 : }
615 :
616 : // ColorList
617 0 : if( *pnColorListState )
618 : {
619 0 : if( *pnColorListState & CT_CHANGED )
620 0 : pColorList = ( (SvxLineTabDialog*) GetParentDialog() )->GetNewColorList();
621 : // aLbColor
622 0 : sal_Int32 nColorPos = m_pLbColor->GetSelectEntryPos();
623 0 : m_pLbColor->Clear();
624 0 : m_pLbColor->Fill( pColorList );
625 0 : nCount = m_pLbColor->GetEntryCount();
626 0 : if( nCount == 0 )
627 : ; // This case should never occur
628 0 : else if( nCount <= nColorPos )
629 0 : m_pLbColor->SelectEntryPos( 0 );
630 : else
631 0 : m_pLbColor->SelectEntryPos( nColorPos );
632 :
633 0 : ChangePreviewHdl_Impl( this );
634 : }
635 :
636 0 : nPageType = 0;
637 : }
638 : // Page does not yet exist in the ctor, that's why we do it here!
639 :
640 0 : else if ( nDlgType == 1100 ||
641 0 : nDlgType == 1101 )
642 : {
643 0 : m_pFlLineEnds->Hide();
644 : // #116827#
645 0 : m_pFLEdgeStyle->Hide();
646 : }
647 0 : }
648 :
649 :
650 :
651 0 : int SvxLineTabPage::DeactivatePage( SfxItemSet* _pSet )
652 : {
653 0 : if( nDlgType == 0 ) // Line dialog
654 : {
655 0 : nPageType = 1; // possibly for extensions
656 0 : *pPosDashLb = m_pLbLineStyle->GetSelectEntryPos() - 2;// First entry SOLID!!!
657 0 : sal_Int32 nPos = m_pLbStartStyle->GetSelectEntryPos();
658 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
659 0 : nPos--;
660 0 : *pPosLineEndLb = nPos;
661 : }
662 :
663 0 : if( _pSet )
664 0 : FillItemSet( *_pSet );
665 :
666 0 : return( LEAVE_PAGE );
667 : }
668 :
669 :
670 :
671 0 : bool SvxLineTabPage::FillItemSet( SfxItemSet& rAttrs )
672 : {
673 0 : const SfxPoolItem* pOld = NULL;
674 : sal_Int32 nPos;
675 0 : sal_Bool bModified = sal_False;
676 :
677 : // To prevent modifications to the list, we do not set other page's items.
678 0 : if( nDlgType != 0 || nPageType != 2 )
679 : {
680 0 : nPos = m_pLbLineStyle->GetSelectEntryPos();
681 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND &&
682 0 : nPos != m_pLbLineStyle->GetSavedValue() )
683 : {
684 0 : XLineStyleItem* pStyleItem = NULL;
685 :
686 0 : if( nPos == 0 )
687 0 : pStyleItem = new XLineStyleItem( XLINE_NONE );
688 0 : else if( nPos == 1 )
689 0 : pStyleItem = new XLineStyleItem( XLINE_SOLID );
690 : else
691 : {
692 0 : pStyleItem = new XLineStyleItem( XLINE_DASH );
693 :
694 : // For added security
695 0 : if( pDashList->Count() > (long) ( nPos - 2 ) )
696 : {
697 : XLineDashItem aDashItem( m_pLbLineStyle->GetSelectEntry(),
698 0 : pDashList->GetDash( nPos - 2 )->GetDash() );
699 0 : pOld = GetOldItem( rAttrs, XATTR_LINEDASH );
700 0 : if ( !pOld || !( *(const XLineDashItem*)pOld == aDashItem ) )
701 : {
702 0 : rAttrs.Put( aDashItem );
703 0 : bModified = sal_True;
704 0 : }
705 : }
706 : }
707 0 : pOld = GetOldItem( rAttrs, XATTR_LINESTYLE );
708 0 : if ( !pOld || !( *(const XLineStyleItem*)pOld == *pStyleItem ) )
709 : {
710 0 : rAttrs.Put( *pStyleItem );
711 0 : bModified = sal_True;
712 : }
713 0 : delete pStyleItem;
714 : }
715 : }
716 : // Line width
717 : // GetSavedValue() returns OUString!
718 0 : if( m_pMtrLineWidth->GetText() != m_pMtrLineWidth->GetSavedValue() )
719 : {
720 0 : XLineWidthItem aItem( GetCoreValue( *m_pMtrLineWidth, ePoolUnit ) );
721 0 : pOld = GetOldItem( rAttrs, XATTR_LINEWIDTH );
722 0 : if ( !pOld || !( *(const XLineWidthItem*)pOld == aItem ) )
723 : {
724 0 : rAttrs.Put( aItem );
725 0 : bModified = sal_True;
726 0 : }
727 : }
728 : // Width line start
729 0 : if( m_pMtrStartWidth->GetText() != m_pMtrStartWidth->GetSavedValue() )
730 : {
731 0 : XLineStartWidthItem aItem( GetCoreValue( *m_pMtrStartWidth, ePoolUnit ) );
732 0 : pOld = GetOldItem( rAttrs, XATTR_LINESTARTWIDTH );
733 0 : if ( !pOld || !( *(const XLineStartWidthItem*)pOld == aItem ) )
734 : {
735 0 : rAttrs.Put( aItem );
736 0 : bModified = sal_True;
737 0 : }
738 : }
739 : // Width line end
740 0 : if( m_pMtrEndWidth->GetText() != m_pMtrEndWidth->GetSavedValue() )
741 : {
742 0 : XLineEndWidthItem aItem( GetCoreValue( *m_pMtrEndWidth, ePoolUnit ) );
743 0 : pOld = GetOldItem( rAttrs, XATTR_LINEENDWIDTH );
744 0 : if ( !pOld || !( *(const XLineEndWidthItem*)pOld == aItem ) )
745 : {
746 0 : rAttrs.Put( aItem );
747 0 : bModified = sal_True;
748 0 : }
749 : }
750 :
751 : // Line color
752 0 : if( m_pLbColor->GetSelectEntryPos() != m_pLbColor->GetSavedValue() )
753 : {
754 0 : XLineColorItem aItem( m_pLbColor->GetSelectEntry(), m_pLbColor->GetSelectEntryColor() );
755 0 : pOld = GetOldItem( rAttrs, XATTR_LINECOLOR );
756 0 : if ( !pOld || !( *(const XLineColorItem*)pOld == aItem ) )
757 : {
758 0 : rAttrs.Put( aItem );
759 0 : bModified = sal_True;
760 0 : }
761 : }
762 :
763 0 : if( nDlgType != 0 || nPageType != 3 )
764 : {
765 : // Line start
766 0 : nPos = m_pLbStartStyle->GetSelectEntryPos();
767 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != m_pLbStartStyle->GetSavedValue() )
768 : {
769 0 : XLineStartItem* pItem = NULL;
770 0 : if( nPos == 0 )
771 0 : pItem = new XLineStartItem();
772 0 : else if( pLineEndList->Count() > (long) ( nPos - 1 ) )
773 0 : pItem = new XLineStartItem( m_pLbStartStyle->GetSelectEntry(), pLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() );
774 0 : pOld = GetOldItem( rAttrs, XATTR_LINESTART );
775 0 : if( pItem && ( !pOld || !( *(const XLineEndItem*)pOld == *pItem ) ) )
776 : {
777 0 : rAttrs.Put( *pItem );
778 0 : bModified = sal_True;
779 : }
780 0 : delete pItem;
781 : }
782 : // Line end
783 0 : nPos = m_pLbEndStyle->GetSelectEntryPos();
784 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != m_pLbEndStyle->GetSavedValue() )
785 : {
786 0 : XLineEndItem* pItem = NULL;
787 0 : if( nPos == 0 )
788 0 : pItem = new XLineEndItem();
789 0 : else if( pLineEndList->Count() > (long) ( nPos - 1 ) )
790 0 : pItem = new XLineEndItem( m_pLbEndStyle->GetSelectEntry(), pLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() );
791 0 : pOld = GetOldItem( rAttrs, XATTR_LINEEND );
792 0 : if( pItem &&
793 0 : ( !pOld || !( *(const XLineEndItem*)pOld == *pItem ) ) )
794 : {
795 0 : rAttrs.Put( *pItem );
796 0 : bModified = sal_True;
797 : }
798 0 : delete pItem;
799 : }
800 : }
801 :
802 : // Centered line end
803 0 : TriState eState = m_pTsbCenterStart->GetState();
804 0 : if( eState != m_pTsbCenterStart->GetSavedValue() )
805 : {
806 0 : XLineStartCenterItem aItem( sal::static_int_cast< sal_Bool >( eState ) );
807 0 : pOld = GetOldItem( rAttrs, XATTR_LINESTARTCENTER );
808 0 : if ( !pOld || !( *(const XLineStartCenterItem*)pOld == aItem ) )
809 : {
810 0 : rAttrs.Put( aItem );
811 0 : bModified = sal_True;
812 0 : }
813 : }
814 0 : eState = m_pTsbCenterEnd->GetState();
815 0 : if( eState != m_pTsbCenterEnd->GetSavedValue() )
816 : {
817 0 : XLineEndCenterItem aItem( sal::static_int_cast< sal_Bool >( eState ) );
818 0 : pOld = GetOldItem( rAttrs, XATTR_LINEENDCENTER );
819 0 : if ( !pOld || !( *(const XLineEndCenterItem*)pOld == aItem ) )
820 : {
821 0 : rAttrs.Put( aItem );
822 0 : bModified = sal_True;
823 0 : }
824 : }
825 :
826 : // Transparency
827 0 : sal_uInt16 nVal = (sal_uInt16)m_pMtrTransparent->GetValue();
828 0 : if( nVal != (sal_uInt16)m_pMtrTransparent->GetSavedValue().toInt32() )
829 : {
830 0 : XLineTransparenceItem aItem( nVal );
831 0 : pOld = GetOldItem( rAttrs, XATTR_LINETRANSPARENCE );
832 0 : if ( !pOld || !( *(const XLineTransparenceItem*)pOld == aItem ) )
833 : {
834 0 : rAttrs.Put( aItem );
835 0 : bModified = sal_True;
836 0 : }
837 : }
838 :
839 : // #116827#
840 0 : nPos = m_pLBEdgeStyle->GetSelectEntryPos();
841 0 : if( LISTBOX_ENTRY_NOTFOUND != nPos && nPos != m_pLBEdgeStyle->GetSavedValue() )
842 : {
843 0 : XLineJointItem* pNew = 0L;
844 :
845 0 : switch(nPos)
846 : {
847 : case 0: // Rounded, default
848 : {
849 0 : pNew = new XLineJointItem(com::sun::star::drawing::LineJoint_ROUND);
850 0 : break;
851 : }
852 : case 1: // - none -
853 : {
854 0 : pNew = new XLineJointItem(com::sun::star::drawing::LineJoint_NONE);
855 0 : break;
856 : }
857 : case 2: // Miter
858 : {
859 0 : pNew = new XLineJointItem(com::sun::star::drawing::LineJoint_MITER);
860 0 : break;
861 : }
862 : case 3: // Bevel
863 : {
864 0 : pNew = new XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL);
865 0 : break;
866 : }
867 : }
868 :
869 0 : if(pNew)
870 : {
871 0 : pOld = GetOldItem( rAttrs, XATTR_LINEJOINT );
872 :
873 0 : if(!pOld || !(*(const XLineJointItem*)pOld == *pNew))
874 : {
875 0 : rAttrs.Put( *pNew );
876 0 : bModified = sal_True;
877 : }
878 :
879 0 : delete pNew;
880 : }
881 : }
882 :
883 : // LineCaps
884 0 : nPos = m_pLBCapStyle->GetSelectEntryPos();
885 0 : if( LISTBOX_ENTRY_NOTFOUND != nPos && nPos != m_pLBCapStyle->GetSavedValue() )
886 : {
887 0 : XLineCapItem* pNew = 0L;
888 :
889 0 : switch(nPos)
890 : {
891 : case 0: // Butt (=Flat), default
892 : {
893 0 : pNew = new XLineCapItem(com::sun::star::drawing::LineCap_BUTT);
894 0 : break;
895 : }
896 : case 1: // Round
897 : {
898 0 : pNew = new XLineCapItem(com::sun::star::drawing::LineCap_ROUND);
899 0 : break;
900 : }
901 : case 2: // Square
902 : {
903 0 : pNew = new XLineCapItem(com::sun::star::drawing::LineCap_SQUARE);
904 0 : break;
905 : }
906 : }
907 :
908 0 : if(pNew)
909 : {
910 0 : pOld = GetOldItem( rAttrs, XATTR_LINECAP );
911 :
912 0 : if(!pOld || !(*(const XLineCapItem*)pOld == *pNew))
913 : {
914 0 : rAttrs.Put( *pNew );
915 0 : bModified = sal_True;
916 : }
917 :
918 0 : delete pNew;
919 : }
920 : }
921 :
922 0 : if(nSymbolType!=SVX_SYMBOLTYPE_UNKNOWN || bNewSize)
923 : {
924 : // Was set by selection or the size is different
925 0 : SvxSizeItem aSItem(rAttrs.GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE),aSymbolSize);
926 0 : const SfxPoolItem* pSOld = GetOldItem( rAttrs, rAttrs.GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE) );
927 0 : bNewSize = pSOld ? *(const SvxSizeItem *)pSOld != aSItem : bNewSize ;
928 0 : if(bNewSize)
929 : {
930 0 : rAttrs.Put(aSItem);
931 0 : bModified=sal_True;
932 : }
933 :
934 0 : SfxInt32Item aTItem(rAttrs.GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE),nSymbolType);
935 0 : const SfxPoolItem* pTOld = GetOldItem( rAttrs, rAttrs.GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE) );
936 0 : bool bNewType = pTOld == NULL || *(const SfxInt32Item*)pTOld != aTItem;
937 0 : if(bNewType && nSymbolType==SVX_SYMBOLTYPE_UNKNOWN)
938 0 : bNewType=false; // a small fix, type wasn't set -> don't create a type item after all!
939 0 : if(bNewType)
940 : {
941 0 : rAttrs.Put(aTItem);
942 0 : bModified=sal_True;
943 : }
944 :
945 0 : if(nSymbolType!=SVX_SYMBOLTYPE_NONE)
946 : {
947 0 : SvxBrushItem aBItem(aSymbolGraphic,GPOS_MM,rAttrs.GetPool()->GetWhich(SID_ATTR_BRUSH));
948 0 : const SfxPoolItem* pBOld = GetOldItem( rAttrs, rAttrs.GetPool()->GetWhich(SID_ATTR_BRUSH) );
949 : bool bNewBrush =
950 0 : pBOld == NULL || *(const SvxBrushItem*)pBOld != aBItem;
951 0 : if(bNewBrush)
952 : {
953 0 : rAttrs.Put(aBItem);
954 0 : bModified=sal_True;
955 0 : }
956 0 : }
957 : }
958 0 : rAttrs.Put (CntUInt16Item(SID_PAGE_TYPE,nPageType));
959 0 : return( bModified );
960 : }
961 :
962 :
963 :
964 0 : sal_Bool SvxLineTabPage::FillXLSet_Impl()
965 : {
966 : sal_Int32 nPos;
967 :
968 0 : if( m_pLbLineStyle->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
969 : {
970 0 : rXLSet.Put( XLineStyleItem( XLINE_NONE ) );
971 : }
972 0 : else if( m_pLbLineStyle->IsEntryPosSelected( 0 ) )
973 0 : rXLSet.Put( XLineStyleItem( XLINE_NONE ) );
974 0 : else if( m_pLbLineStyle->IsEntryPosSelected( 1 ) )
975 0 : rXLSet.Put( XLineStyleItem( XLINE_SOLID ) );
976 : else
977 : {
978 0 : rXLSet.Put( XLineStyleItem( XLINE_DASH ) );
979 :
980 0 : nPos = m_pLbLineStyle->GetSelectEntryPos();
981 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
982 : {
983 : rXLSet.Put( XLineDashItem( m_pLbLineStyle->GetSelectEntry(),
984 0 : pDashList->GetDash( nPos - 2 )->GetDash() ) );
985 : }
986 : }
987 :
988 0 : nPos = m_pLbStartStyle->GetSelectEntryPos();
989 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
990 : {
991 0 : if( nPos == 0 )
992 0 : rXLSet.Put( XLineStartItem() );
993 : else
994 : rXLSet.Put( XLineStartItem( m_pLbStartStyle->GetSelectEntry(),
995 0 : pLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ) );
996 : }
997 0 : nPos = m_pLbEndStyle->GetSelectEntryPos();
998 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
999 : {
1000 0 : if( nPos == 0 )
1001 0 : rXLSet.Put( XLineEndItem() );
1002 : else
1003 : rXLSet.Put( XLineEndItem( m_pLbEndStyle->GetSelectEntry(),
1004 0 : pLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ) );
1005 : }
1006 :
1007 : // #116827#
1008 0 : nPos = m_pLBEdgeStyle->GetSelectEntryPos();
1009 0 : if(LISTBOX_ENTRY_NOTFOUND != nPos)
1010 : {
1011 0 : switch(nPos)
1012 : {
1013 : case 0: // Rounded, default
1014 : {
1015 0 : rXLSet.Put(XLineJointItem(com::sun::star::drawing::LineJoint_ROUND));
1016 0 : break;
1017 : }
1018 : case 1: // - none -
1019 : {
1020 0 : rXLSet.Put(XLineJointItem(com::sun::star::drawing::LineJoint_NONE));
1021 0 : break;
1022 : }
1023 : case 2: // Miter
1024 : {
1025 0 : rXLSet.Put(XLineJointItem(com::sun::star::drawing::LineJoint_MITER));
1026 0 : break;
1027 : }
1028 : case 3: // Bevel
1029 : {
1030 0 : rXLSet.Put(XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL));
1031 0 : break;
1032 : }
1033 : }
1034 : }
1035 :
1036 : // LineCaps
1037 0 : nPos = m_pLBCapStyle->GetSelectEntryPos();
1038 0 : if(LISTBOX_ENTRY_NOTFOUND != nPos)
1039 : {
1040 0 : switch(nPos)
1041 : {
1042 : case 0: // Butt (=Flat), default
1043 : {
1044 0 : rXLSet.Put(XLineCapItem(com::sun::star::drawing::LineCap_BUTT));
1045 0 : break;
1046 : }
1047 : case 1: // Round
1048 : {
1049 0 : rXLSet.Put(XLineCapItem(com::sun::star::drawing::LineCap_ROUND));
1050 0 : break;
1051 : }
1052 : case 2: // Square
1053 : {
1054 0 : rXLSet.Put(XLineCapItem(com::sun::star::drawing::LineCap_SQUARE));
1055 0 : break;
1056 : }
1057 : }
1058 : }
1059 :
1060 0 : rXLSet.Put( XLineStartWidthItem( GetCoreValue( *m_pMtrStartWidth, ePoolUnit ) ) );
1061 0 : rXLSet.Put( XLineEndWidthItem( GetCoreValue( *m_pMtrEndWidth, ePoolUnit ) ) );
1062 :
1063 0 : rXLSet.Put( XLineWidthItem( GetCoreValue( *m_pMtrLineWidth, ePoolUnit ) ) );
1064 0 : rXLSet.Put( XLineColorItem( m_pLbColor->GetSelectEntry(), m_pLbColor->GetSelectEntryColor() ) );
1065 :
1066 : // Centered line end
1067 0 : if( m_pTsbCenterStart->GetState() == TRISTATE_TRUE )
1068 0 : rXLSet.Put( XLineStartCenterItem( true ) );
1069 0 : else if( m_pTsbCenterStart->GetState() == TRISTATE_FALSE )
1070 0 : rXLSet.Put( XLineStartCenterItem( false ) );
1071 :
1072 0 : if( m_pTsbCenterEnd->GetState() == TRISTATE_TRUE )
1073 0 : rXLSet.Put( XLineEndCenterItem( true ) );
1074 0 : else if( m_pTsbCenterEnd->GetState() == TRISTATE_FALSE )
1075 0 : rXLSet.Put( XLineEndCenterItem( false ) );
1076 :
1077 : // Transparency
1078 0 : sal_uInt16 nVal = (sal_uInt16)m_pMtrTransparent->GetValue();
1079 0 : rXLSet.Put( XLineTransparenceItem( nVal ) );
1080 :
1081 : // #116827#
1082 0 : m_pCtlPreview->SetLineAttributes(aXLineAttr.GetItemSet());
1083 :
1084 0 : return( sal_True );
1085 : }
1086 :
1087 :
1088 :
1089 0 : void SvxLineTabPage::Reset( const SfxItemSet& rAttrs )
1090 : {
1091 : XLineStyle eXLS; // XLINE_NONE, XLINE_SOLID, XLINE_DASH
1092 :
1093 : // Line style
1094 : const SfxPoolItem *pPoolItem;
1095 0 : long nSymType=SVX_SYMBOLTYPE_UNKNOWN;
1096 0 : sal_Bool bPrevSym=sal_False;
1097 0 : sal_Bool bEnable=sal_True;
1098 0 : sal_Bool bIgnoreGraphic=sal_False;
1099 0 : sal_Bool bIgnoreSize=sal_False;
1100 0 : if(rAttrs.GetItemState(rAttrs.GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE),true,&pPoolItem) == SFX_ITEM_SET)
1101 : {
1102 0 : nSymType=((const SfxInt32Item *)pPoolItem)->GetValue();
1103 : }
1104 :
1105 0 : if(nSymType == SVX_SYMBOLTYPE_AUTO)
1106 : {
1107 0 : aSymbolGraphic=aAutoSymbolGraphic;
1108 0 : aSymbolSize=aSymbolLastSize=aAutoSymbolGraphic.GetPrefSize();
1109 0 : bPrevSym=sal_True;
1110 : }
1111 0 : else if(nSymType == SVX_SYMBOLTYPE_NONE)
1112 : {
1113 0 : bEnable=sal_False;
1114 0 : bIgnoreGraphic=sal_True;
1115 0 : bIgnoreSize=sal_True;
1116 : }
1117 0 : else if(nSymType >= 0)
1118 : {
1119 0 : VirtualDevice aVDev;
1120 0 : aVDev.SetMapMode(MapMode(MAP_100TH_MM));
1121 :
1122 0 : SdrModel* pModel = new SdrModel;
1123 0 : pModel->GetItemPool().FreezeIdRanges();
1124 0 : SdrPage* pPage = new SdrPage( *pModel, false );
1125 0 : pPage->SetSize(Size(1000,1000));
1126 0 : pModel->InsertPage( pPage, 0 );
1127 0 : SdrView* pView = new SdrView( pModel, &aVDev );
1128 0 : pView->hideMarkHandles();
1129 0 : pView->ShowSdrPage(pPage);
1130 0 : SdrObject *pObj=NULL;
1131 0 : long nSymTmp=nSymType;
1132 0 : if(pSymbolList)
1133 : {
1134 0 : if(pSymbolList->GetObjCount())
1135 : {
1136 0 : nSymTmp=nSymTmp%pSymbolList->GetObjCount(); // Treat list as cyclic!
1137 0 : pObj=pSymbolList->GetObj(nSymTmp);
1138 0 : if(pObj)
1139 : {
1140 0 : pObj=pObj->Clone();
1141 0 : if(pSymbolAttr)
1142 : {
1143 0 : pObj->SetMergedItemSet(*pSymbolAttr);
1144 : }
1145 : else
1146 : {
1147 0 : pObj->SetMergedItemSet(rOutAttrs);
1148 : }
1149 :
1150 0 : pPage->NbcInsertObject(pObj);
1151 :
1152 : // Generate invisible square to give all symbol types a
1153 : // bitmap size, which is independent from specific glyph
1154 0 : SdrObject *pInvisibleSquare=pSymbolList->GetObj(0);
1155 0 : pInvisibleSquare=pInvisibleSquare->Clone();
1156 0 : pPage->NbcInsertObject(pInvisibleSquare);
1157 0 : pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100));
1158 0 : pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100));
1159 :
1160 0 : pView->MarkAll();
1161 0 : GDIMetaFile aMeta(pView->GetMarkedObjMetaFile());
1162 :
1163 0 : aSymbolGraphic=Graphic(aMeta);
1164 0 : aSymbolSize=pObj->GetSnapRect().GetSize();
1165 0 : aSymbolGraphic.SetPrefSize(pInvisibleSquare->GetSnapRect().GetSize());
1166 0 : aSymbolGraphic.SetPrefMapMode(MAP_100TH_MM);
1167 0 : bPrevSym=sal_True;
1168 0 : bEnable=sal_True;
1169 0 : bIgnoreGraphic=sal_True;
1170 :
1171 0 : pView->UnmarkAll();
1172 0 : pInvisibleSquare=pPage->RemoveObject(1);
1173 0 : SdrObject::Free( pInvisibleSquare);
1174 0 : pObj=pPage->RemoveObject(0);
1175 0 : SdrObject::Free( pObj );
1176 : }
1177 : }
1178 : }
1179 0 : delete pView;
1180 0 : delete pModel;
1181 : }
1182 0 : if(rAttrs.GetItemState(rAttrs.GetPool()->GetWhich(SID_ATTR_BRUSH),true,&pPoolItem) == SFX_ITEM_SET)
1183 : {
1184 0 : const Graphic* pGraphic = ((const SvxBrushItem *)pPoolItem)->GetGraphic();
1185 0 : if( pGraphic )
1186 : {
1187 0 : if(!bIgnoreGraphic)
1188 : {
1189 0 : aSymbolGraphic=*pGraphic;
1190 : }
1191 0 : if(!bIgnoreSize)
1192 : {
1193 : aSymbolSize=OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
1194 : pGraphic->GetPrefMapMode(),
1195 0 : MAP_100TH_MM );
1196 : }
1197 0 : bPrevSym=sal_True;
1198 : }
1199 : }
1200 :
1201 0 : if(rAttrs.GetItemState(rAttrs.GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE),true,&pPoolItem) == SFX_ITEM_SET)
1202 : {
1203 0 : aSymbolSize = ((const SvxSizeItem *)pPoolItem)->GetSize();
1204 : }
1205 :
1206 0 : m_pGridIconSize->Enable(bEnable);
1207 :
1208 0 : if(bPrevSym)
1209 : {
1210 0 : SetMetricValue(*m_pSymbolWidthMF, aSymbolSize.Width(), ePoolUnit);
1211 0 : SetMetricValue(*m_pSymbolHeightMF, aSymbolSize.Height(),ePoolUnit);
1212 0 : m_pCtlPreview->SetSymbol(&aSymbolGraphic,aSymbolSize);
1213 0 : aSymbolLastSize=aSymbolSize;
1214 : }
1215 :
1216 0 : if( rAttrs.GetItemState( XATTR_LINESTYLE ) != SFX_ITEM_DONTCARE )
1217 : {
1218 0 : eXLS = (XLineStyle) ( ( const XLineStyleItem& ) rAttrs.Get( XATTR_LINESTYLE ) ).GetValue();
1219 :
1220 0 : switch( eXLS )
1221 : {
1222 : case XLINE_NONE:
1223 0 : m_pLbLineStyle->SelectEntryPos( 0 );
1224 0 : break;
1225 : case XLINE_SOLID:
1226 0 : m_pLbLineStyle->SelectEntryPos( 1 );
1227 0 : break;
1228 :
1229 : case XLINE_DASH:
1230 0 : m_pLbLineStyle->SetNoSelection();
1231 0 : m_pLbLineStyle->SelectEntry( ( ( const XLineDashItem& ) rAttrs.Get( XATTR_LINEDASH ) ).GetName() );
1232 0 : break;
1233 :
1234 : default:
1235 0 : break;
1236 : }
1237 : }
1238 : else
1239 : {
1240 0 : m_pLbLineStyle->SetNoSelection();
1241 : }
1242 :
1243 : // Line strength
1244 0 : if( rAttrs.GetItemState( XATTR_LINEWIDTH ) != SFX_ITEM_DONTCARE )
1245 : {
1246 0 : SetMetricValue( *m_pMtrLineWidth, ( ( const XLineWidthItem& ) rAttrs.Get( XATTR_LINEWIDTH ) ).GetValue(), ePoolUnit );
1247 : }
1248 : else
1249 0 : m_pMtrLineWidth->SetText( "" );
1250 :
1251 : // Line color
1252 0 : m_pLbColor->SetNoSelection();
1253 :
1254 0 : if ( rAttrs.GetItemState( XATTR_LINECOLOR ) != SFX_ITEM_DONTCARE )
1255 : {
1256 0 : Color aCol = ( ( const XLineColorItem& ) rAttrs.Get( XATTR_LINECOLOR ) ).GetColorValue();
1257 0 : m_pLbColor->SelectEntry( aCol );
1258 0 : if( m_pLbColor->GetSelectEntryCount() == 0 )
1259 : {
1260 0 : m_pLbColor->InsertEntry( aCol, OUString() );
1261 0 : m_pLbColor->SelectEntry( aCol );
1262 : }
1263 : }
1264 :
1265 : // Line start
1266 0 : if( bObjSelected && rAttrs.GetItemState( XATTR_LINESTART ) == SFX_ITEM_DEFAULT )
1267 : {
1268 0 : m_pLbStartStyle->Disable();
1269 : }
1270 0 : else if( rAttrs.GetItemState( XATTR_LINESTART ) != SFX_ITEM_DONTCARE )
1271 : {
1272 : // #86265# select entry using list and polygon, not string
1273 0 : sal_Bool bSelected(sal_False);
1274 0 : const basegfx::B2DPolyPolygon& rItemPolygon = ((const XLineStartItem&)rAttrs.Get(XATTR_LINESTART)).GetLineStartValue();
1275 :
1276 0 : for(sal_Int32 a(0);!bSelected && a < pLineEndList->Count(); a++)
1277 : {
1278 0 : XLineEndEntry* pEntry = pLineEndList->GetLineEnd(a);
1279 0 : const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
1280 :
1281 0 : if(rItemPolygon == rEntryPolygon)
1282 : {
1283 : // select this entry
1284 0 : m_pLbStartStyle->SelectEntryPos(a + 1);
1285 0 : bSelected = sal_True;
1286 : }
1287 : }
1288 :
1289 0 : if(!bSelected)
1290 0 : m_pLbStartStyle->SelectEntryPos( 0 );
1291 : }
1292 : else
1293 : {
1294 0 : m_pLbStartStyle->SetNoSelection();
1295 : }
1296 :
1297 : // Line end
1298 0 : if( bObjSelected && rAttrs.GetItemState( XATTR_LINEEND ) == SFX_ITEM_DEFAULT )
1299 : {
1300 0 : m_pLbEndStyle->Disable();
1301 : }
1302 0 : else if( rAttrs.GetItemState( XATTR_LINEEND ) != SFX_ITEM_DONTCARE )
1303 : {
1304 : // #86265# select entry using list and polygon, not string
1305 0 : sal_Bool bSelected(sal_False);
1306 0 : const basegfx::B2DPolyPolygon& rItemPolygon = ((const XLineEndItem&)rAttrs.Get(XATTR_LINEEND)).GetLineEndValue();
1307 :
1308 0 : for(sal_Int32 a(0);!bSelected && a < pLineEndList->Count(); a++)
1309 : {
1310 0 : XLineEndEntry* pEntry = pLineEndList->GetLineEnd(a);
1311 0 : const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
1312 :
1313 0 : if(rItemPolygon == rEntryPolygon)
1314 : {
1315 : // select this entry
1316 0 : m_pLbEndStyle->SelectEntryPos(a + 1);
1317 0 : bSelected = sal_True;
1318 : }
1319 : }
1320 :
1321 0 : if(!bSelected)
1322 0 : m_pLbEndStyle->SelectEntryPos( 0 );
1323 : }
1324 : else
1325 : {
1326 0 : m_pLbEndStyle->SetNoSelection();
1327 : }
1328 :
1329 : // Line start strength
1330 0 : if( bObjSelected && rAttrs.GetItemState( XATTR_LINESTARTWIDTH ) == SFX_ITEM_DEFAULT )
1331 : {
1332 0 : m_pMtrStartWidth->Disable();
1333 : }
1334 0 : else if( rAttrs.GetItemState( XATTR_LINESTARTWIDTH ) != SFX_ITEM_DONTCARE )
1335 : {
1336 : SetMetricValue( *m_pMtrStartWidth,
1337 0 : ( ( const XLineStartWidthItem& ) rAttrs.Get( XATTR_LINESTARTWIDTH ) ).GetValue(),
1338 0 : ePoolUnit );
1339 : }
1340 : else
1341 0 : m_pMtrStartWidth->SetText( "" );
1342 :
1343 : // Line end strength
1344 0 : if( bObjSelected && rAttrs.GetItemState( XATTR_LINEENDWIDTH ) == SFX_ITEM_DEFAULT )
1345 : {
1346 0 : m_pMtrEndWidth->Disable();
1347 : }
1348 0 : else if( rAttrs.GetItemState( XATTR_LINEENDWIDTH ) != SFX_ITEM_DONTCARE )
1349 : {
1350 : SetMetricValue( *m_pMtrEndWidth,
1351 0 : ( ( const XLineEndWidthItem& ) rAttrs.Get( XATTR_LINEENDWIDTH ) ).GetValue(),
1352 0 : ePoolUnit );
1353 : }
1354 : else
1355 0 : m_pMtrEndWidth->SetText( "" );
1356 :
1357 : // Centered line end (start)
1358 0 : if( bObjSelected && rAttrs.GetItemState( XATTR_LINESTARTCENTER ) == SFX_ITEM_DEFAULT )
1359 : {
1360 0 : m_pTsbCenterStart->Disable();
1361 : }
1362 0 : else if( rAttrs.GetItemState( XATTR_LINESTARTCENTER ) != SFX_ITEM_DONTCARE )
1363 : {
1364 0 : m_pTsbCenterStart->EnableTriState( false );
1365 :
1366 0 : if( ( ( const XLineStartCenterItem& ) rAttrs.Get( XATTR_LINESTARTCENTER ) ).GetValue() )
1367 0 : m_pTsbCenterStart->SetState( TRISTATE_TRUE );
1368 : else
1369 0 : m_pTsbCenterStart->SetState( TRISTATE_FALSE );
1370 : }
1371 : else
1372 : {
1373 0 : m_pTsbCenterStart->SetState( TRISTATE_INDET );
1374 : }
1375 :
1376 : // Centered line end (end)
1377 0 : if( bObjSelected && rAttrs.GetItemState( XATTR_LINEENDCENTER ) == SFX_ITEM_DEFAULT )
1378 : {
1379 0 : m_pTsbCenterEnd->Disable();
1380 : }
1381 0 : else if( rAttrs.GetItemState( XATTR_LINEENDCENTER ) != SFX_ITEM_DONTCARE )
1382 : {
1383 0 : m_pTsbCenterEnd->EnableTriState( false );
1384 :
1385 0 : if( ( ( const XLineEndCenterItem& ) rAttrs.Get( XATTR_LINEENDCENTER ) ).GetValue() )
1386 0 : m_pTsbCenterEnd->SetState( TRISTATE_TRUE );
1387 : else
1388 0 : m_pTsbCenterEnd->SetState( TRISTATE_FALSE );
1389 : }
1390 : else
1391 : {
1392 0 : m_pTsbCenterEnd->SetState( TRISTATE_INDET );
1393 : }
1394 :
1395 : // Transparency
1396 0 : if( rAttrs.GetItemState( XATTR_LINETRANSPARENCE ) != SFX_ITEM_DONTCARE )
1397 : {
1398 0 : sal_uInt16 nTransp = ( ( const XLineTransparenceItem& ) rAttrs.Get( XATTR_LINETRANSPARENCE ) ).GetValue();
1399 0 : m_pMtrTransparent->SetValue( nTransp );
1400 0 : ChangeTransparentHdl_Impl( NULL );
1401 : }
1402 : else
1403 0 : m_pMtrTransparent->SetText( "" );
1404 :
1405 0 : if( !m_pLbStartStyle->IsEnabled() &&
1406 0 : !m_pLbEndStyle->IsEnabled() &&
1407 0 : !m_pMtrStartWidth->IsEnabled() &&
1408 0 : !m_pMtrEndWidth->IsEnabled() &&
1409 0 : !m_pTsbCenterStart->IsEnabled()&&
1410 0 : !m_pTsbCenterEnd->IsEnabled() )
1411 : {
1412 0 : m_pCbxSynchronize->Disable();
1413 0 : m_pFlLineEnds->Disable();
1414 : }
1415 :
1416 : // Synchronize
1417 : // We get the value from the INI file now
1418 0 : OUString aStr = GetUserData();
1419 0 : m_pCbxSynchronize->Check( (sal_Bool)aStr.toInt32() );
1420 :
1421 : // #116827#
1422 0 : if(bObjSelected && SFX_ITEM_DEFAULT == rAttrs.GetItemState(XATTR_LINEJOINT))
1423 : {
1424 : // maFTEdgeStyle.Disable();
1425 0 : m_pLBEdgeStyle->Disable();
1426 : }
1427 0 : else if(SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_LINEJOINT))
1428 : {
1429 0 : const com::sun::star::drawing::LineJoint eLineJoint = ((const XLineJointItem&)(rAttrs.Get(XATTR_LINEJOINT))).GetValue();
1430 :
1431 0 : switch(eLineJoint)
1432 : {
1433 : case com::sun::star::drawing::LineJoint_MAKE_FIXED_SIZE: // fallback to round, unused value
1434 : case com::sun::star::drawing::LineJoint_MIDDLE : // fallback to round, unused value
1435 0 : case com::sun::star::drawing::LineJoint_ROUND : m_pLBEdgeStyle->SelectEntryPos(0); break;
1436 0 : case com::sun::star::drawing::LineJoint_NONE : m_pLBEdgeStyle->SelectEntryPos(1); break;
1437 0 : case com::sun::star::drawing::LineJoint_MITER : m_pLBEdgeStyle->SelectEntryPos(2); break;
1438 0 : case com::sun::star::drawing::LineJoint_BEVEL : m_pLBEdgeStyle->SelectEntryPos(3); break;
1439 : }
1440 : }
1441 : else
1442 : {
1443 0 : m_pLBEdgeStyle->SetNoSelection();
1444 : }
1445 :
1446 : // fdo#43209
1447 0 : if(bObjSelected && SFX_ITEM_DEFAULT == rAttrs.GetItemState(XATTR_LINECAP))
1448 : {
1449 : // maFTCapStyle.Disable();
1450 0 : m_pLBCapStyle->Disable();
1451 : }
1452 0 : else if(SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_LINECAP))
1453 : {
1454 0 : const com::sun::star::drawing::LineCap eLineCap(((const XLineCapItem&)(rAttrs.Get(XATTR_LINECAP))).GetValue());
1455 :
1456 0 : switch(eLineCap)
1457 : {
1458 0 : case com::sun::star::drawing::LineCap_ROUND: m_pLBCapStyle->SelectEntryPos(1); break;
1459 0 : case com::sun::star::drawing::LineCap_SQUARE : m_pLBCapStyle->SelectEntryPos(2); break;
1460 0 : default /*com::sun::star::drawing::LineCap_BUTT*/: m_pLBCapStyle->SelectEntryPos(0); break;
1461 : }
1462 : }
1463 : else
1464 : {
1465 0 : m_pLBCapStyle->SetNoSelection();
1466 : }
1467 :
1468 : // Save values
1469 0 : m_pLbLineStyle->SaveValue();
1470 0 : m_pMtrLineWidth->SaveValue();
1471 0 : m_pLbColor->SaveValue();
1472 0 : m_pLbStartStyle->SaveValue();
1473 0 : m_pLbEndStyle->SaveValue();
1474 0 : m_pMtrStartWidth->SaveValue();
1475 0 : m_pMtrEndWidth->SaveValue();
1476 0 : m_pTsbCenterStart->SaveValue();
1477 0 : m_pTsbCenterEnd->SaveValue();
1478 0 : m_pMtrTransparent->SaveValue();
1479 :
1480 : // #116827#
1481 0 : m_pLBEdgeStyle->SaveValue();
1482 :
1483 : // LineCaps
1484 0 : m_pLBCapStyle->SaveValue();
1485 :
1486 0 : ClickInvisibleHdl_Impl( this );
1487 :
1488 0 : ChangePreviewHdl_Impl( NULL );
1489 0 : }
1490 :
1491 :
1492 :
1493 0 : SfxTabPage* SvxLineTabPage::Create( Window* pWindow,
1494 : const SfxItemSet& rAttrs )
1495 : {
1496 0 : return( new SvxLineTabPage( pWindow, rAttrs ) );
1497 : }
1498 :
1499 :
1500 :
1501 0 : sal_uInt16* SvxLineTabPage::GetRanges()
1502 : {
1503 0 : return pLineRanges;
1504 : }
1505 :
1506 :
1507 :
1508 0 : IMPL_LINK( SvxLineTabPage, ChangePreviewHdl_Impl, void *, pCntrl )
1509 : {
1510 0 : if(pCntrl == m_pMtrLineWidth)
1511 : {
1512 : // Line width and start end width
1513 0 : sal_Int32 nNewLineWidth = GetCoreValue( *m_pMtrLineWidth, ePoolUnit );
1514 0 : if(nActLineWidth == -1)
1515 : {
1516 : // Don't initialize yet, get the start value
1517 0 : const SfxPoolItem* pOld = GetOldItem( rXLSet, XATTR_LINEWIDTH );
1518 0 : sal_Int32 nStartLineWidth = 0;
1519 0 : if(pOld)
1520 0 : nStartLineWidth = (( const XLineWidthItem *)pOld)->GetValue();
1521 0 : nActLineWidth = nStartLineWidth;
1522 : }
1523 :
1524 0 : if(nActLineWidth != nNewLineWidth)
1525 : {
1526 : // Adapt start/end width
1527 0 : sal_Int32 nValAct = GetCoreValue( *m_pMtrStartWidth, ePoolUnit );
1528 0 : sal_Int32 nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
1529 0 : if(nValNew < 0)
1530 0 : nValNew = 0;
1531 0 : SetMetricValue( *m_pMtrStartWidth, nValNew, ePoolUnit );
1532 :
1533 0 : nValAct = GetCoreValue( *m_pMtrEndWidth, ePoolUnit );
1534 0 : nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
1535 0 : if(nValNew < 0)
1536 0 : nValNew = 0;
1537 0 : SetMetricValue( *m_pMtrEndWidth, nValNew, ePoolUnit );
1538 : }
1539 :
1540 : // Remember current value
1541 0 : nActLineWidth = nNewLineWidth;
1542 : }
1543 :
1544 0 : FillXLSet_Impl();
1545 0 : m_pCtlPreview->Invalidate();
1546 :
1547 : // Make transparency accessible accordingly
1548 0 : if( m_pLbLineStyle->GetSelectEntryPos() == 0 ) // invisible
1549 : {
1550 0 : m_pBoxTransparency->Disable();
1551 : }
1552 : else
1553 : {
1554 0 : m_pBoxTransparency->Enable();
1555 : }
1556 :
1557 0 : const bool bHasLineStyle = m_pLbLineStyle->GetSelectEntryPos() !=0;
1558 0 : const bool bHasLineStart = m_pLbStartStyle->GetSelectEntryPos() != 0;
1559 :
1560 0 : m_pBoxStart->Enable(bHasLineStart && bHasLineStyle);
1561 :
1562 0 : const bool bHasLineEnd = m_pLbEndStyle->GetSelectEntryPos() != 0;
1563 :
1564 0 : m_pBoxEnd->Enable(bHasLineEnd && bHasLineStyle);
1565 :
1566 0 : return( 0L );
1567 : }
1568 :
1569 :
1570 :
1571 0 : IMPL_LINK( SvxLineTabPage, ChangeStartHdl_Impl, void *, p )
1572 : {
1573 0 : if( m_pCbxSynchronize->IsChecked() )
1574 : {
1575 0 : if( p == m_pMtrStartWidth )
1576 0 : m_pMtrEndWidth->SetValue( m_pMtrStartWidth->GetValue() );
1577 0 : if( p == m_pLbStartStyle )
1578 0 : m_pLbEndStyle->SelectEntryPos( m_pLbStartStyle->GetSelectEntryPos() );
1579 0 : if( p == m_pTsbCenterStart )
1580 0 : m_pTsbCenterEnd->SetState( m_pTsbCenterStart->GetState() );
1581 : }
1582 :
1583 0 : ChangePreviewHdl_Impl( this );
1584 :
1585 0 : return( 0L );
1586 : }
1587 :
1588 :
1589 : // #116827#
1590 :
1591 0 : IMPL_LINK_NOARG(SvxLineTabPage, ChangeEdgeStyleHdl_Impl)
1592 : {
1593 0 : ChangePreviewHdl_Impl( this );
1594 :
1595 0 : return( 0L );
1596 : }
1597 :
1598 :
1599 : // fdo#43209
1600 :
1601 0 : IMPL_LINK( SvxLineTabPage, ChangeCapStyleHdl_Impl, void *, EMPTYARG )
1602 : {
1603 0 : ChangePreviewHdl_Impl( this );
1604 :
1605 0 : return( 0L );
1606 : }
1607 :
1608 :
1609 0 : IMPL_LINK_NOARG(SvxLineTabPage, ClickInvisibleHdl_Impl)
1610 : {
1611 0 : if( m_pLbLineStyle->GetSelectEntryPos() == 0 ) // invisible
1612 : {
1613 0 : if(!bSymbols)
1614 0 : m_pBoxColor->Disable();
1615 :
1616 0 : m_pBoxWidth->Disable();
1617 :
1618 0 : if( m_pFlLineEnds->IsEnabled() )
1619 : {
1620 0 : m_pBoxStart->Disable();
1621 0 : m_pBoxArrowStyles->Disable();
1622 :
1623 :
1624 : // #116827#
1625 0 : m_pGridEdgeCaps->Disable();
1626 : }
1627 : }
1628 : else
1629 : {
1630 0 : m_pBoxColor->Enable();
1631 0 : m_pBoxWidth->Enable();
1632 :
1633 0 : if( m_pFlLineEnds->IsEnabled() )
1634 : {
1635 0 : m_pBoxArrowStyles->Enable();
1636 : // #116827#
1637 0 : m_pGridEdgeCaps->Enable();
1638 : }
1639 : }
1640 0 : ChangePreviewHdl_Impl( NULL );
1641 :
1642 0 : return( 0L );
1643 : }
1644 :
1645 :
1646 :
1647 0 : IMPL_LINK( SvxLineTabPage, ChangeEndHdl_Impl, void *, p )
1648 : {
1649 0 : if( m_pCbxSynchronize->IsChecked() )
1650 : {
1651 0 : if( p == m_pMtrEndWidth )
1652 0 : m_pMtrStartWidth->SetValue( m_pMtrEndWidth->GetValue() );
1653 0 : if( p == m_pLbEndStyle )
1654 0 : m_pLbStartStyle->SelectEntryPos( m_pLbEndStyle->GetSelectEntryPos() );
1655 0 : if( p == m_pTsbCenterEnd )
1656 0 : m_pTsbCenterStart->SetState( m_pTsbCenterEnd->GetState() );
1657 : }
1658 :
1659 0 : ChangePreviewHdl_Impl( this );
1660 :
1661 0 : return( 0L );
1662 : }
1663 :
1664 :
1665 :
1666 0 : IMPL_LINK_NOARG(SvxLineTabPage, ChangeTransparentHdl_Impl)
1667 : {
1668 0 : sal_uInt16 nVal = (sal_uInt16)m_pMtrTransparent->GetValue();
1669 0 : XLineTransparenceItem aItem( nVal );
1670 :
1671 0 : rXLSet.Put( XLineTransparenceItem( aItem ) );
1672 :
1673 : // #116827#
1674 0 : FillXLSet_Impl();
1675 :
1676 0 : m_pCtlPreview->Invalidate();
1677 :
1678 0 : return( 0L );
1679 : }
1680 :
1681 :
1682 :
1683 0 : void SvxLineTabPage::PointChanged( Window*, RECT_POINT eRcPt )
1684 : {
1685 0 : eRP = eRcPt;
1686 0 : }
1687 :
1688 :
1689 :
1690 0 : void SvxLineTabPage::FillUserData()
1691 : {
1692 : // Write the synched value to the INI file
1693 : // OUString aStrUserData = OUString::valueOf( (sal_Int32) m_pCbxSynchronize->IsChecked() );
1694 0 : OUString aStrUserData = OUString::boolean(m_pCbxSynchronize->IsChecked());
1695 0 : SetUserData( aStrUserData );
1696 0 : }
1697 :
1698 :
1699 : // #58425# Symbols on a list (e.g. StarChart)
1700 : // Handler for the symbol selection's popup menu (NumMenueButton)
1701 : // The following link originates from SvxNumOptionsTabPage
1702 0 : IMPL_LINK( SvxLineTabPage, MenuCreateHdl_Impl, MenuButton *, pButton )
1703 : {
1704 0 : InitSymbols(pButton);
1705 0 : return 0;
1706 : }
1707 : // #58425# Symbols on a list (e.g. StarChart)
1708 : // Handler for the symbol selection's popup menu (NumMenueButton)
1709 : // The following link originates from SvxNumOptionsTabPage
1710 0 : IMPL_STATIC_LINK(SvxLineTabPage, GraphicArrivedHdl_Impl, SvxBrushItem*, pItem)
1711 : {
1712 0 : PopupMenu* pPopup = pThis->m_pSymbolMB->GetPopupMenu()->GetPopupMenu( MN_GALLERY );
1713 :
1714 0 : SvxBmpItemInfo* pBmpInfo = 0;
1715 0 : for ( size_t i = 0; i < pThis->aGrfBrushItems.size(); i++ )
1716 : {
1717 0 : SvxBmpItemInfo* pInfo = pThis->aGrfBrushItems[ i ];
1718 0 : if( pInfo->pBrushItem == pItem )
1719 : {
1720 0 : pBmpInfo = pInfo; break;
1721 : }
1722 : }
1723 0 : if( pBmpInfo )
1724 : {
1725 0 : const Graphic* pGraphic = pItem->GetGraphic();
1726 0 : if (pGraphic)
1727 : {
1728 0 : Bitmap aBitmap(pGraphic->GetBitmap());
1729 0 : Size aSize(aBitmap.GetSizePixel());
1730 0 : if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT)
1731 : {
1732 0 : sal_Bool bWidth = aSize.Width() > aSize.Height();
1733 : double nScale = bWidth ?
1734 0 : (double)MAX_BMP_WIDTH / (double)aSize.Width():
1735 0 : (double)MAX_BMP_HEIGHT / (double)aSize.Height();
1736 0 : aBitmap.Scale(nScale, nScale);
1737 : }
1738 0 : Image aImage(aBitmap);
1739 0 : pPopup->SetItemImage( pBmpInfo->nItemId, aImage );
1740 : }
1741 : }
1742 :
1743 0 : return 0;
1744 : }
1745 :
1746 : // #58425# Symbols on a list (e.g. StarChart)
1747 : // Handler for menu button
1748 0 : IMPL_LINK( SvxLineTabPage, GraphicHdl_Impl, MenuButton *, pButton )
1749 : {
1750 0 : SymbolSelected(pButton);
1751 0 : return 0;
1752 : }
1753 0 : IMPL_LINK( SvxLineTabPage, SizeHdl_Impl, MetricField *, pField)
1754 : {
1755 0 : bNewSize=true;
1756 0 : sal_Bool bWidth = (sal_Bool)(pField == m_pSymbolWidthMF);
1757 0 : bLastWidthModified = bWidth;
1758 0 : sal_Bool bRatio = m_pSymbolRatioCB->IsChecked();
1759 0 : long nWidthVal = static_cast<long>(m_pSymbolWidthMF->Denormalize(m_pSymbolWidthMF->GetValue(FUNIT_100TH_MM)));
1760 0 : long nHeightVal= static_cast<long>(m_pSymbolHeightMF->Denormalize(m_pSymbolHeightMF->GetValue(FUNIT_100TH_MM)));
1761 0 : nWidthVal = OutputDevice::LogicToLogic(nWidthVal,MAP_100TH_MM,(MapUnit)ePoolUnit );
1762 0 : nHeightVal = OutputDevice::LogicToLogic(nHeightVal,MAP_100TH_MM,(MapUnit)ePoolUnit);
1763 0 : aSymbolSize=Size(nWidthVal,nHeightVal);
1764 0 : double fSizeRatio = (double)1;
1765 :
1766 0 : if(bRatio)
1767 : {
1768 0 : if (aSymbolLastSize.Height() && aSymbolLastSize.Width())
1769 0 : fSizeRatio = (double)aSymbolLastSize.Width() / aSymbolLastSize.Height();
1770 : }
1771 :
1772 : //Size aSymbolSize(aSymbolLastSize);
1773 :
1774 0 : if(bWidth)
1775 : {
1776 0 : long nDelta = nWidthVal - aSymbolLastSize.Width();
1777 0 : aSymbolSize.Width() = nWidthVal;
1778 0 : if (bRatio)
1779 : {
1780 0 : aSymbolSize.Height() = aSymbolLastSize.Height() + (long)((double)nDelta / fSizeRatio);
1781 0 : aSymbolSize.Height() = OutputDevice::LogicToLogic( aSymbolSize.Height(),(MapUnit)ePoolUnit, MAP_100TH_MM );
1782 0 : m_pSymbolHeightMF->SetUserValue(m_pSymbolHeightMF->Normalize(aSymbolSize.Height()), FUNIT_100TH_MM);
1783 : }
1784 : }
1785 : else
1786 : {
1787 0 : long nDelta = nHeightVal - aSymbolLastSize.Height();
1788 0 : aSymbolSize.Height() = nHeightVal;
1789 0 : if (bRatio)
1790 : {
1791 0 : aSymbolSize.Width() = aSymbolLastSize.Width() + (long)((double)nDelta * fSizeRatio);
1792 0 : aSymbolSize.Width() = OutputDevice::LogicToLogic( aSymbolSize.Width(), (MapUnit)ePoolUnit, MAP_100TH_MM );
1793 0 : m_pSymbolWidthMF->SetUserValue(m_pSymbolWidthMF->Normalize(aSymbolSize.Width()), FUNIT_100TH_MM);
1794 : }
1795 : }
1796 0 : m_pCtlPreview->ResizeSymbol(aSymbolSize);
1797 0 : aSymbolLastSize=aSymbolSize;
1798 0 : return 0;
1799 : }
1800 0 : IMPL_LINK( SvxLineTabPage, RatioHdl_Impl, CheckBox *, pBox )
1801 : {
1802 0 : if (pBox->IsChecked())
1803 : {
1804 0 : if (bLastWidthModified)
1805 0 : SizeHdl_Impl(m_pSymbolWidthMF);
1806 : else
1807 0 : SizeHdl_Impl(m_pSymbolHeightMF);
1808 : }
1809 0 : return 0;
1810 : }
1811 :
1812 :
1813 0 : void SvxLineTabPage::DataChanged( const DataChangedEvent& rDCEvt )
1814 : {
1815 0 : SvxTabPage::DataChanged( rDCEvt );
1816 :
1817 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1818 : {
1819 0 : FillListboxes();
1820 : }
1821 0 : }
1822 :
1823 0 : void SvxLineTabPage::PageCreated (SfxAllItemSet aSet)
1824 : {
1825 0 : SFX_ITEMSET_ARG (&aSet,pColorListItem,SvxColorListItem,SID_COLOR_TABLE,false);
1826 0 : SFX_ITEMSET_ARG (&aSet,pDashListItem,SvxDashListItem,SID_DASH_LIST,false);
1827 0 : SFX_ITEMSET_ARG (&aSet,pLineEndListItem,SvxLineEndListItem,SID_LINEEND_LIST,false);
1828 0 : SFX_ITEMSET_ARG (&aSet,pPageTypeItem,SfxUInt16Item,SID_PAGE_TYPE,false);
1829 0 : SFX_ITEMSET_ARG (&aSet,pDlgTypeItem,SfxUInt16Item,SID_DLG_TYPE,false);
1830 0 : SFX_ITEMSET_ARG (&aSet,pSdrObjListItem,OfaPtrItem,SID_OBJECT_LIST,false);
1831 0 : SFX_ITEMSET_ARG (&aSet,pSymbolAttrItem,SfxTabDialogItem,SID_ATTR_SET,false);
1832 0 : SFX_ITEMSET_ARG (&aSet,pGraphicItem,SvxGraphicItem,SID_GRAPHIC,false);
1833 :
1834 0 : if (pColorListItem)
1835 0 : SetColorList(pColorListItem->GetColorList());
1836 0 : if (pDashListItem)
1837 0 : SetDashList(pDashListItem->GetDashList());
1838 0 : if (pLineEndListItem)
1839 0 : SetLineEndList(pLineEndListItem->GetLineEndList());
1840 0 : if (pPageTypeItem)
1841 0 : SetPageType(pPageTypeItem->GetValue());
1842 0 : if (pDlgTypeItem)
1843 0 : SetDlgType(pDlgTypeItem->GetValue());
1844 0 : Construct();
1845 :
1846 0 : if(pSdrObjListItem) //symbols
1847 : {
1848 0 : ShowSymbolControls(sal_True);
1849 0 : pSymbolList = static_cast<SdrObjList*>(pSdrObjListItem->GetValue());
1850 0 : if (pSymbolAttrItem)
1851 0 : pSymbolAttr = new SfxItemSet(pSymbolAttrItem->GetItemSet());
1852 0 : if(pGraphicItem)
1853 0 : aAutoSymbolGraphic = pGraphicItem->GetGraphic();
1854 : }
1855 0 : }
1856 :
1857 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|