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