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