1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <editeng/sizeitem.hxx>
21 #include <tools/urlobj.hxx>
22 #include <sfx2/app.hxx>
23 #include <sfx2/module.hxx>
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>
56 #define MAX_BMP_WIDTH 16
57 #define MAX_BMP_HEIGHT 16
61 #define MN_SYMBOLS_NONE 1
62 #define MN_SYMBOLS_AUTO 2
63 #define MN_GALLERY_ENTRY 100
65 using namespace com::sun::star
;
67 // static ----------------------------------------------------------------
69 const sal_uInt16
SvxLineTabPage::pLineRanges
[] =
71 XATTR_LINETRANSPARENCE
,
72 XATTR_LINETRANSPARENCE
,
74 SID_ATTR_LINE_ENDCENTER
,
78 SvxLineTabPage::SvxLineTabPage
81 const SfxItemSet
& rInAttrs
85 ,"cui/ui/linetabpage.ui"
90 nNumMenuGalleryItems(0),
91 nSymbolType(SVX_SYMBOLTYPE_UNKNOWN
), // unknown respectively unchanged
94 bLastWidthModified(false),
95 aSymbolLastSize(Size(0,0)),
98 rOutAttrs ( rInAttrs
),
100 bObjSelected( false ),
102 pXPool ( static_cast<XOutdevItemPool
*>(rInAttrs
.GetPool()) ),
103 aXLStyle ( drawing::LineStyle_DASH
),
105 aXDash ( OUString(), XDash( css::drawing::DashStyle_RECT
, 3, 7, 2, 40, 15 ) ),
106 aXColor ( OUString(), COL_LIGHTRED
),
107 aXLineAttr ( pXPool
),
108 rXLSet ( aXLineAttr
.GetItemSet() ),
109 pnLineEndListState( 0 ),
110 pnDashListState( 0 ),
111 pnColorListState( 0 ),
118 get(m_pLbLineStyle
,"LB_LINE_STYLE");
119 get(m_pBoxColor
,"boxCOLOR");
120 get(m_pLbColor
,"LB_COLOR");
121 get(m_pBoxWidth
,"boxWIDTH");
122 get(m_pMtrLineWidth
,"MTR_FLD_LINE_WIDTH");
123 get(m_pBoxTransparency
,"boxTRANSPARENCY");
124 get(m_pMtrTransparent
,"MTR_LINE_TRANSPARENT");
126 get(m_pFlLineEnds
,"FL_LINE_ENDS");
127 get(m_pBoxArrowStyles
,"boxARROW_STYLES");
128 get(m_pLbStartStyle
,"LB_START_STYLE");
129 get(m_pBoxStart
,"boxSTART");
130 get(m_pMtrStartWidth
,"MTR_FLD_START_WIDTH");
131 get(m_pTsbCenterStart
,"TSB_CENTER_START");
132 get(m_pBoxEnd
,"boxEND");
133 get(m_pLbEndStyle
,"LB_END_STYLE");
134 get(m_pMtrEndWidth
,"MTR_FLD_END_WIDTH");
135 get(m_pTsbCenterEnd
,"TSB_CENTER_END");
136 get(m_pCbxSynchronize
,"CBX_SYNCHRONIZE");
137 get(m_pCtlPreview
,"CTL_PREVIEW");
139 get(m_pGridEdgeCaps
,"gridEDGE_CAPS");
140 get(m_pFLEdgeStyle
,"FL_EDGE_STYLE");
141 get(m_pLBEdgeStyle
,"LB_EDGE_STYLE");
143 get(m_pLBCapStyle
,"LB_CAP_STYLE");
145 //#58425# Symbols on a line (e.g. StarChart)
146 get(m_pFlSymbol
,"FL_SYMBOL_FORMAT");
147 get(m_pGridIconSize
,"gridICON_SIZE");
148 get(m_pSymbolMB
,"MB_SYMBOL_BITMAP");
149 get(m_pSymbolWidthMF
,"MF_SYMBOL_WIDTH");
150 get(m_pSymbolHeightMF
,"MF_SYMBOL_HEIGHT");
151 get(m_pSymbolRatioCB
,"CB_SYMBOL_RATIO");
153 // This Page requires ExchangeSupport
154 SetExchangeSupport();
157 FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
164 // no break -> we now have mm
166 m_pMtrLineWidth
->SetSpinSize( 50 );
167 m_pMtrStartWidth
->SetSpinSize( 50 );
168 m_pMtrEndWidth
->SetSpinSize( 50 );
172 m_pMtrLineWidth
->SetSpinSize( 2 );
173 m_pMtrStartWidth
->SetSpinSize( 2 );
174 m_pMtrEndWidth
->SetSpinSize( 2 );
176 default: ;// prevent warning
178 SetFieldUnit( *m_pMtrLineWidth
, eFUnit
);
179 SetFieldUnit( *m_pMtrStartWidth
, eFUnit
);
180 SetFieldUnit( *m_pMtrEndWidth
, eFUnit
);
182 // determine PoolUnit
183 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
184 DBG_ASSERT( pPool
, "Where is the pool?" );
185 ePoolUnit
= pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
187 m_pLbLineStyle
->SetSelectHdl( LINK( this, SvxLineTabPage
, ClickInvisibleHdl_Impl
) );
188 m_pLbColor
->SetSelectHdl( LINK( this, SvxLineTabPage
, ChangePreviewHdl_Impl
) );
189 m_pMtrLineWidth
->SetModifyHdl( LINK( this, SvxLineTabPage
, ChangePreviewHdl_Impl
) );
190 m_pMtrTransparent
->SetModifyHdl( LINK( this, SvxLineTabPage
, ChangeTransparentHdl_Impl
) );
192 Link
<> aStart
= LINK( this, SvxLineTabPage
, ChangeStartHdl_Impl
);
193 Link
<> aEnd
= LINK( this, SvxLineTabPage
, ChangeEndHdl_Impl
);
194 m_pLbStartStyle
->SetSelectHdl( aStart
);
195 m_pLbEndStyle
->SetSelectHdl( aEnd
);
196 m_pMtrStartWidth
->SetModifyHdl( aStart
);
197 m_pMtrEndWidth
->SetModifyHdl( aEnd
);
198 m_pTsbCenterStart
->SetClickHdl( aStart
);
199 m_pTsbCenterEnd
->SetClickHdl( aEnd
);
202 Link
<> aEdgeStyle
= LINK( this, SvxLineTabPage
, ChangeEdgeStyleHdl_Impl
);
203 m_pLBEdgeStyle
->SetSelectHdl( aEdgeStyle
);
206 Link
<> aCapStyle
= LINK( this, SvxLineTabPage
, ChangeCapStyleHdl_Impl
);
207 m_pLBCapStyle
->SetSelectHdl( aCapStyle
);
209 // Symbols on a line (eg star charts), MB-handler set
210 m_pSymbolMB
->SetSelectHdl(LINK(this, SvxLineTabPage
, GraphicHdl_Impl
));
211 m_pSymbolMB
->SetActivateHdl(LINK(this, SvxLineTabPage
, MenuCreateHdl_Impl
));
212 m_pSymbolWidthMF
->SetModifyHdl(LINK(this, SvxLineTabPage
, SizeHdl_Impl
));
213 m_pSymbolHeightMF
->SetModifyHdl(LINK(this, SvxLineTabPage
, SizeHdl_Impl
));
214 m_pSymbolRatioCB
->SetClickHdl(LINK(this, SvxLineTabPage
, RatioHdl_Impl
));
216 m_pSymbolRatioCB
->Check(true);
217 ShowSymbolControls(false);
222 void SvxLineTabPage::ShowSymbolControls(bool bOn
)
224 // Symbols on a line (e.g. StarCharts), symbol-enable controls
227 m_pFlSymbol
->Show(bOn
);
228 m_pCtlPreview
->ShowSymbol(bOn
);
231 SvxLineTabPage::~SvxLineTabPage()
236 void SvxLineTabPage::dispose()
238 // Symbols on a line (e.g. StarCharts), dtor new!
241 delete m_pSymbolMB
->GetPopupMenu()->GetPopupMenu( MN_GALLERY
);
244 delete m_pSymbolMB
->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS
);
248 for ( size_t i
= 0, n
= aGrfBrushItems
.size(); i
< n
; ++i
)
250 SvxBmpItemInfo
* pInfo
= aGrfBrushItems
[ i
];
251 delete pInfo
->pBrushItem
;
254 aGrfBrushItems
.clear();
257 m_pLbLineStyle
.clear();
260 m_pMtrLineWidth
.clear();
261 m_pBoxTransparency
.clear();
262 m_pMtrTransparent
.clear();
263 m_pFlLineEnds
.clear();
264 m_pBoxArrowStyles
.clear();
265 m_pLbStartStyle
.clear();
267 m_pMtrStartWidth
.clear();
268 m_pTsbCenterStart
.clear();
270 m_pLbEndStyle
.clear();
271 m_pMtrEndWidth
.clear();
272 m_pTsbCenterEnd
.clear();
273 m_pCbxSynchronize
.clear();
274 m_pCtlPreview
.clear();
275 m_pFLEdgeStyle
.clear();
276 m_pGridEdgeCaps
.clear();
277 m_pLBEdgeStyle
.clear();
278 m_pLBCapStyle
.clear();
280 m_pGridIconSize
.clear();
282 m_pSymbolWidthMF
.clear();
283 m_pSymbolHeightMF
.clear();
284 m_pSymbolRatioCB
.clear();
285 SvxTabPage::dispose();
288 void SvxLineTabPage::Construct()
291 m_pLbColor
->Fill( pColorList
);
295 void SvxLineTabPage::InitSymbols(MenuButton
* pButton
)
298 if(!pButton
->GetPopupMenu()->GetPopupMenu( MN_GALLERY
))
300 // Get gallery entries
301 GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS
, aGrfNames
);
303 PopupMenu
* pPopup
= new PopupMenu
;
306 nNumMenuGalleryItems
= aGrfNames
.size();
307 for(std::vector
<OUString
>::iterator it
= aGrfNames
.begin(); it
!= aGrfNames
.end(); ++it
, ++i
)
309 const OUString
*pUIName
= &(*it
);
311 // Convert URL encodings to UI characters (e.g. %20 for spaces)
312 OUString aPhysicalName
;
313 if (utl::LocalFileHelper::ConvertURLToPhysicalName(*it
, aPhysicalName
))
315 pUIName
= &aPhysicalName
;
318 SvxBrushItem
* pBrushItem
= new SvxBrushItem(*it
, aEmptyStr
, GPOS_AREA
, SID_ATTR_BRUSH
);
319 pBrushItem
->SetDoneLink(LINK(this, SvxLineTabPage
, GraphicArrivedHdl_Impl
));
321 SvxBmpItemInfo
* pInfo
= new SvxBmpItemInfo();
322 pInfo
->pBrushItem
= pBrushItem
;
323 pInfo
->nItemId
= (sal_uInt16
)(MN_GALLERY_ENTRY
+ i
);
324 if ( i
< aGrfBrushItems
.size() )
326 aGrfBrushItems
.insert( aGrfBrushItems
.begin() + i
, pInfo
);
329 aGrfBrushItems
.push_back( pInfo
);
331 const Graphic
* pGraphic
= pBrushItem
->GetGraphic();
335 Bitmap
aBitmap(pGraphic
->GetBitmap());
336 Size
aSize(aBitmap
.GetSizePixel());
337 if(aSize
.Width() > MAX_BMP_WIDTH
|| aSize
.Height() > MAX_BMP_HEIGHT
)
339 bool bWidth
= aSize
.Width() > aSize
.Height();
340 double nScale
= bWidth
?
341 (double)MAX_BMP_WIDTH
/ (double)aSize
.Width():
342 (double)MAX_BMP_HEIGHT
/ (double)aSize
.Height();
343 aBitmap
.Scale(nScale
, nScale
);
346 Image
aImage(aBitmap
);
347 pPopup
->InsertItem(pInfo
->nItemId
, *pUIName
, aImage
);
352 pPopup
->InsertItem(pInfo
->nItemId
, *pUIName
, aImage
);
355 m_pSymbolMB
->GetPopupMenu()->SetPopupMenu( MN_GALLERY
, pPopup
);
357 if(aGrfNames
.empty())
358 m_pSymbolMB
->GetPopupMenu()->EnableItem(MN_GALLERY
, false);
361 if(!pButton
->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS
) && pSymbolList
)
363 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
364 pVDev
->SetMapMode(MapMode(MAP_100TH_MM
));
365 boost::scoped_ptr
<SdrModel
> pModel(new SdrModel
);
366 pModel
->GetItemPool().FreezeIdRanges();
368 SdrPage
* pPage
= new SdrPage( *pModel
, false );
369 pPage
->SetSize(Size(1000,1000));
370 pModel
->InsertPage( pPage
, 0 );
373 boost::scoped_ptr
<SdrView
> pView(new SdrView( pModel
.get(), pVDev
));
374 pView
->hideMarkHandles();
375 pView
->ShowSdrPage(pPage
);
377 PopupMenu
* pPopup
= new PopupMenu
;
380 // Generate invisible square to give all symbols a
381 // bitmap size, which is independent from specific glyph
382 SdrObject
*pInvisibleSquare
=pSymbolList
->GetObj(0);
383 pInvisibleSquare
=pInvisibleSquare
->Clone();
384 pPage
->NbcInsertObject(pInvisibleSquare
);
385 pInvisibleSquare
->SetMergedItem(XFillTransparenceItem(100));
386 pInvisibleSquare
->SetMergedItem(XLineTransparenceItem(100));
388 for(size_t i
=0;; ++i
)
390 SdrObject
*pObj
=pSymbolList
->GetObj(i
);
394 aGrfNames
.push_back(aEmptyStr
);
395 pPage
->NbcInsertObject(pObj
);
398 pObj
->SetMergedItemSet(*pSymbolAttr
);
402 pObj
->SetMergedItemSet(rOutAttrs
);
405 BitmapEx
aBitmapEx(pView
->GetMarkedObjBitmapEx());
406 GDIMetaFile
aMeta(pView
->GetMarkedObjMetaFile());
408 pObj
=pPage
->RemoveObject(1);
409 SdrObject::Free(pObj
);
411 SvxBrushItem
* pBrushItem
= new SvxBrushItem(Graphic(aMeta
), GPOS_AREA
, SID_ATTR_BRUSH
);
412 pBrushItem
->SetDoneLink(LINK(this, SvxLineTabPage
, GraphicArrivedHdl_Impl
));
414 SvxBmpItemInfo
* pInfo
= new SvxBmpItemInfo();
415 pInfo
->pBrushItem
= pBrushItem
;
416 pInfo
->nItemId
= (sal_uInt16
)(MN_GALLERY_ENTRY
+ i
+ nNumMenuGalleryItems
);
417 if ( (size_t)(nNumMenuGalleryItems
+ i
) < aGrfBrushItems
.size() ) {
418 aGrfBrushItems
.insert( aGrfBrushItems
.begin() + nNumMenuGalleryItems
+ i
, pInfo
);
420 aGrfBrushItems
.push_back( pInfo
);
423 Size
aSize(aBitmapEx
.GetSizePixel());
424 if(aSize
.Width() > MAX_BMP_WIDTH
|| aSize
.Height() > MAX_BMP_HEIGHT
)
426 bool bWidth
= aSize
.Width() > aSize
.Height();
427 double nScale
= bWidth
?
428 (double)MAX_BMP_WIDTH
/ (double)aSize
.Width():
429 (double)MAX_BMP_HEIGHT
/ (double)aSize
.Height();
430 aBitmapEx
.Scale(nScale
, nScale
);
432 Image
aImage(aBitmapEx
);
433 pPopup
->InsertItem(pInfo
->nItemId
,aEmptyStr
,aImage
);
435 pInvisibleSquare
=pPage
->RemoveObject(0);
436 SdrObject::Free(pInvisibleSquare
);
438 m_pSymbolMB
->GetPopupMenu()->SetPopupMenu( MN_SYMBOLS
, pPopup
);
440 if(aGrfNames
.empty())
441 m_pSymbolMB
->GetPopupMenu()->EnableItem(MN_SYMBOLS
, false);
447 void SvxLineTabPage::SymbolSelected(MenuButton
* pButton
)
449 sal_uInt16 nItemId
= pButton
->GetCurItemId();
450 const Graphic
* pGraphic
= 0;
452 bool bResetSize
= false;
454 long nPreviousSymbolType
= nSymbolType
;
456 if(nItemId
>= MN_GALLERY_ENTRY
)
458 if( (nItemId
-MN_GALLERY_ENTRY
) >= nNumMenuGalleryItems
)
460 nSymbolType
=nItemId
-MN_GALLERY_ENTRY
-nNumMenuGalleryItems
; // List's index
464 nSymbolType
=SVX_SYMBOLTYPE_BRUSHITEM
;
467 SvxBmpItemInfo
* pInfo
= aGrfBrushItems
[ nItemId
- MN_GALLERY_ENTRY
];
468 pGraphic
= pInfo
->pBrushItem
->GetGraphic();
472 case MN_SYMBOLS_AUTO
:
474 pGraphic
=&aAutoSymbolGraphic
;
475 aAutoSymbolGraphic
.SetPrefSize( Size(253,253) );
476 nSymbolType
=SVX_SYMBOLTYPE_AUTO
;
480 case MN_SYMBOLS_NONE
:
482 nSymbolType
=SVX_SYMBOLTYPE_NONE
;
489 SvxOpenGraphicDialog
aGrfDlg(CUI_RES(RID_SVXSTR_EDIT_GRAPHIC
));
490 aGrfDlg
.EnableLink(false);
491 aGrfDlg
.AsLink(false);
492 if( !aGrfDlg
.Execute() )
494 // Remember selected filters
495 if( !aGrfDlg
.GetGraphic(aGraphic
) )
497 nSymbolType
=SVX_SYMBOLTYPE_BRUSHITEM
;
498 pGraphic
= &aGraphic
;
510 Size aSize
= SvxNumberFormat::GetGraphicSizeMM100(pGraphic
);
511 aSize
= OutputDevice::LogicToLogic(aSize
, MAP_100TH_MM
, (MapUnit
)ePoolUnit
);
512 aSymbolGraphic
=*pGraphic
;
517 else if( nPreviousSymbolType
== SVX_SYMBOLTYPE_BRUSHITEM
)
518 { //#i31097# Data Point Symbol size changes when a different symbol is chosen(maoyg)
519 if( aSymbolSize
.Width() != aSymbolSize
.Height() )
521 aSize
.setWidth( (long)( aSymbolSize
.Width() + aSymbolSize
.Height() )/2 );
522 aSize
.setHeight( (long)( aSymbolSize
.Width() + aSymbolSize
.Height() )/2 );
526 m_pCtlPreview
->SetSymbol(&aSymbolGraphic
,aSymbolSize
);
530 aSymbolGraphic
=Graphic();
531 m_pCtlPreview
->SetSymbol(NULL
,aSymbolSize
);
534 aSymbolLastSize
=aSymbolSize
;
535 SetMetricValue(*m_pSymbolWidthMF
, aSymbolSize
.Width(), ePoolUnit
);
536 SetMetricValue(*m_pSymbolHeightMF
, aSymbolSize
.Height(), ePoolUnit
);
538 m_pGridIconSize
->Enable(bEnable
);
539 m_pCtlPreview
->Invalidate();
542 void SvxLineTabPage::FillListboxes()
545 sal_Int32 nOldSelect
= m_pLbLineStyle
->GetSelectEntryPos();
546 // aLbLineStyle.FillStyles();
547 m_pLbLineStyle
->Fill( pDashList
);
548 m_pLbLineStyle
->SelectEntryPos( nOldSelect
);
551 OUString
sNone( SVX_RES( RID_SVXSTR_NONE
) );
552 nOldSelect
= m_pLbStartStyle
->GetSelectEntryPos();
553 m_pLbStartStyle
->Clear();
554 m_pLbStartStyle
->InsertEntry( sNone
);
555 m_pLbStartStyle
->Fill( pLineEndList
);
556 m_pLbStartStyle
->SelectEntryPos( nOldSelect
);
557 nOldSelect
= m_pLbEndStyle
->GetSelectEntryPos();
558 m_pLbEndStyle
->Clear();
559 m_pLbEndStyle
->InsertEntry( sNone
);
560 m_pLbEndStyle
->Fill( pLineEndList
, false );
561 m_pLbEndStyle
->SelectEntryPos( nOldSelect
);
566 void SvxLineTabPage::ActivatePage( const SfxItemSet
& rSet
)
568 SFX_ITEMSET_ARG (&rSet
,pPageTypeItem
,CntUInt16Item
,SID_PAGE_TYPE
,false);
570 SetPageType(pPageTypeItem
->GetValue());
571 if( nDlgType
== 0 && pDashList
.is() )
577 if( ( *pnDashListState
& ChangeType::MODIFIED
) ||
578 ( *pnDashListState
& ChangeType::CHANGED
) )
580 if( *pnDashListState
& ChangeType::CHANGED
)
581 pDashList
= static_cast<SvxLineTabDialog
*>( GetParentDialog() )->GetNewDashList();
583 *pnDashListState
= ChangeType::NONE
;
586 nPos
= m_pLbLineStyle
->GetSelectEntryPos();
588 m_pLbLineStyle
->Clear();
589 m_pLbLineStyle
->InsertEntry( SVX_RESSTR( RID_SVXSTR_INVISIBLE
) );
590 m_pLbLineStyle
->InsertEntry( SVX_RESSTR( RID_SVXSTR_SOLID
) );
591 m_pLbLineStyle
->Fill( pDashList
);
592 nCount
= m_pLbLineStyle
->GetEntryCount();
595 ; // This case should never occur
596 else if( nCount
<= nPos
)
597 m_pLbLineStyle
->SelectEntryPos( 0 );
599 m_pLbLineStyle
->SelectEntryPos( nPos
);
600 // SelectStyleHdl_Impl( this );
603 INetURLObject
aDashURL( pDashList
->GetPath() );
605 aDashURL
.Append( pDashList
->GetName() );
606 DBG_ASSERT( aDashURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
608 if( ( *pnLineEndListState
& ChangeType::MODIFIED
) || ( *pnLineEndListState
& ChangeType::CHANGED
) )
610 if( *pnLineEndListState
& ChangeType::CHANGED
)
611 pLineEndList
= static_cast<SvxLineTabDialog
*>( GetParentDialog() )->GetNewLineEndList();
613 *pnLineEndListState
= ChangeType::NONE
;
615 nPos
= m_pLbLineStyle
->GetSelectEntryPos();
616 OUString
sNone( SVX_RES( RID_SVXSTR_NONE
) );
617 m_pLbStartStyle
->Clear();
618 m_pLbStartStyle
->InsertEntry( sNone
);
620 m_pLbStartStyle
->Fill( pLineEndList
);
621 nCount
= m_pLbStartStyle
->GetEntryCount();
623 ; // This case should never occur
624 else if( nCount
<= nPos
)
625 m_pLbStartStyle
->SelectEntryPos( 0 );
627 m_pLbStartStyle
->SelectEntryPos( nPos
);
629 m_pLbEndStyle
->Clear();
630 m_pLbEndStyle
->InsertEntry( sNone
);
632 m_pLbEndStyle
->Fill( pLineEndList
, false );
633 nCount
= m_pLbEndStyle
->GetEntryCount();
636 ; // This case should never occur
637 else if( nCount
<= nPos
)
638 m_pLbEndStyle
->SelectEntryPos( 0 );
640 m_pLbEndStyle
->SelectEntryPos( nPos
);
642 INetURLObject
aLineURL( pLineEndList
->GetPath() );
644 aLineURL
.Append( pLineEndList
->GetName() );
645 DBG_ASSERT( aLineURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
646 // Evaluate if another TabPage set another fill type
647 if( m_pLbLineStyle
->GetSelectEntryPos() != 0 )
649 if( nPageType
== 2 ) // 1
651 m_pLbLineStyle
->SelectEntryPos( *pPosDashLb
+ 2 ); // +2 due to SOLID and INVLISIBLE
652 ChangePreviewHdl_Impl( this );
656 m_pLbStartStyle
->SelectEntryPos( *pPosLineEndLb
+ 1 );// +1 due to SOLID
657 m_pLbEndStyle
->SelectEntryPos( *pPosLineEndLb
+ 1 );// +1 due to SOLID
658 ChangePreviewHdl_Impl( this );
663 if( *pnColorListState
!= ChangeType::NONE
)
665 if( *pnColorListState
& ChangeType::CHANGED
)
666 pColorList
= static_cast<SvxLineTabDialog
*>( GetParentDialog() )->GetNewColorList();
668 sal_Int32 nColorPos
= m_pLbColor
->GetSelectEntryPos();
670 m_pLbColor
->Fill( pColorList
);
671 nCount
= m_pLbColor
->GetEntryCount();
673 ; // This case should never occur
674 else if( nCount
<= nColorPos
)
675 m_pLbColor
->SelectEntryPos( 0 );
677 m_pLbColor
->SelectEntryPos( nColorPos
);
679 ChangePreviewHdl_Impl( this );
684 // Page does not yet exist in the ctor, that's why we do it here!
686 else if ( nDlgType
== 1100 ||
689 m_pFlLineEnds
->Hide();
691 m_pFLEdgeStyle
->Hide();
697 SfxTabPage::sfxpg
SvxLineTabPage::DeactivatePage( SfxItemSet
* _pSet
)
699 if( nDlgType
== 0 ) // Line dialog
701 nPageType
= 1; // possibly for extensions
702 *pPosDashLb
= m_pLbLineStyle
->GetSelectEntryPos() - 2;// First entry SOLID!!!
703 sal_Int32 nPos
= m_pLbStartStyle
->GetSelectEntryPos();
704 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
706 *pPosLineEndLb
= nPos
;
710 FillItemSet( _pSet
);
717 bool SvxLineTabPage::FillItemSet( SfxItemSet
* rAttrs
)
719 const SfxPoolItem
* pOld
= NULL
;
721 bool bModified
= false;
723 // To prevent modifications to the list, we do not set other page's items.
724 if( nDlgType
!= 0 || nPageType
!= 2 )
726 nPos
= m_pLbLineStyle
->GetSelectEntryPos();
727 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&&
728 m_pLbLineStyle
->IsValueChangedFromSaved() )
730 boost::scoped_ptr
<XLineStyleItem
> pStyleItem
;
733 pStyleItem
.reset(new XLineStyleItem( drawing::LineStyle_NONE
));
735 pStyleItem
.reset(new XLineStyleItem( drawing::LineStyle_SOLID
));
738 pStyleItem
.reset(new XLineStyleItem( drawing::LineStyle_DASH
));
740 // For added security
741 if( pDashList
->Count() > (long) ( nPos
- 2 ) )
743 XLineDashItem
aDashItem( m_pLbLineStyle
->GetSelectEntry(),
744 pDashList
->GetDash( nPos
- 2 )->GetDash() );
745 pOld
= GetOldItem( *rAttrs
, XATTR_LINEDASH
);
746 if ( !pOld
|| !( *static_cast<const XLineDashItem
*>(pOld
) == aDashItem
) )
748 rAttrs
->Put( aDashItem
);
753 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTYLE
);
754 if ( !pOld
|| !( *static_cast<const XLineStyleItem
*>(pOld
) == *pStyleItem
) )
756 rAttrs
->Put( *pStyleItem
);
762 // GetSavedValue() returns OUString!
763 if( m_pMtrLineWidth
->IsValueChangedFromSaved() )
765 XLineWidthItem
aItem( GetCoreValue( *m_pMtrLineWidth
, ePoolUnit
) );
766 pOld
= GetOldItem( *rAttrs
, XATTR_LINEWIDTH
);
767 if ( !pOld
|| !( *static_cast<const XLineWidthItem
*>(pOld
) == aItem
) )
769 rAttrs
->Put( aItem
);
774 if( m_pMtrStartWidth
->IsValueChangedFromSaved() )
776 XLineStartWidthItem
aItem( GetCoreValue( *m_pMtrStartWidth
, ePoolUnit
) );
777 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTARTWIDTH
);
778 if ( !pOld
|| !( *static_cast<const XLineStartWidthItem
*>(pOld
) == aItem
) )
780 rAttrs
->Put( aItem
);
785 if( m_pMtrEndWidth
->IsValueChangedFromSaved() )
787 XLineEndWidthItem
aItem( GetCoreValue( *m_pMtrEndWidth
, ePoolUnit
) );
788 pOld
= GetOldItem( *rAttrs
, XATTR_LINEENDWIDTH
);
789 if ( !pOld
|| !( *static_cast<const XLineEndWidthItem
*>(pOld
) == aItem
) )
791 rAttrs
->Put( aItem
);
797 if( m_pLbColor
->IsValueChangedFromSaved() )
799 XLineColorItem
aItem( m_pLbColor
->GetSelectEntry(), m_pLbColor
->GetSelectEntryColor() );
800 pOld
= GetOldItem( *rAttrs
, XATTR_LINECOLOR
);
801 if ( !pOld
|| !( *static_cast<const XLineColorItem
*>(pOld
) == aItem
) )
803 rAttrs
->Put( aItem
);
808 if( nDlgType
!= 0 || nPageType
!= 3 )
811 nPos
= m_pLbStartStyle
->GetSelectEntryPos();
812 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&& m_pLbStartStyle
->IsValueChangedFromSaved() )
814 boost::scoped_ptr
<XLineStartItem
> pItem
;
816 pItem
.reset(new XLineStartItem());
817 else if( pLineEndList
->Count() > (long) ( nPos
- 1 ) )
818 pItem
.reset(new XLineStartItem( m_pLbStartStyle
->GetSelectEntry(), pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ));
819 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTART
);
820 if( pItem
&& ( !pOld
|| !( *static_cast<const XLineEndItem
*>(pOld
) == *pItem
) ) )
822 rAttrs
->Put( *pItem
);
827 nPos
= m_pLbEndStyle
->GetSelectEntryPos();
828 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
&& m_pLbEndStyle
->IsValueChangedFromSaved() )
830 boost::scoped_ptr
<XLineEndItem
> pItem
;
832 pItem
.reset(new XLineEndItem());
833 else if( pLineEndList
->Count() > (long) ( nPos
- 1 ) )
834 pItem
.reset(new XLineEndItem( m_pLbEndStyle
->GetSelectEntry(), pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ));
835 pOld
= GetOldItem( *rAttrs
, XATTR_LINEEND
);
837 ( !pOld
|| !( *static_cast<const XLineEndItem
*>(pOld
) == *pItem
) ) )
839 rAttrs
->Put( *pItem
);
846 TriState eState
= m_pTsbCenterStart
->GetState();
847 if( m_pTsbCenterStart
->IsValueChangedFromSaved() )
849 XLineStartCenterItem
aItem( eState
!= TRISTATE_FALSE
);
850 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTARTCENTER
);
851 if ( !pOld
|| !( *static_cast<const XLineStartCenterItem
*>(pOld
) == aItem
) )
853 rAttrs
->Put( aItem
);
857 eState
= m_pTsbCenterEnd
->GetState();
858 if( m_pTsbCenterEnd
->IsValueChangedFromSaved() )
860 XLineEndCenterItem
aItem( eState
!= TRISTATE_FALSE
);
861 pOld
= GetOldItem( *rAttrs
, XATTR_LINEENDCENTER
);
862 if ( !pOld
|| !( *static_cast<const XLineEndCenterItem
*>(pOld
) == aItem
) )
864 rAttrs
->Put( aItem
);
870 sal_uInt16 nVal
= (sal_uInt16
)m_pMtrTransparent
->GetValue();
871 if( m_pMtrTransparent
->IsValueChangedFromSaved() )
873 XLineTransparenceItem
aItem( nVal
);
874 pOld
= GetOldItem( *rAttrs
, XATTR_LINETRANSPARENCE
);
875 if ( !pOld
|| !( *static_cast<const XLineTransparenceItem
*>(pOld
) == aItem
) )
877 rAttrs
->Put( aItem
);
883 nPos
= m_pLBEdgeStyle
->GetSelectEntryPos();
884 if( LISTBOX_ENTRY_NOTFOUND
!= nPos
&& m_pLBEdgeStyle
->IsValueChangedFromSaved() )
886 boost::scoped_ptr
<XLineJointItem
> pNew
;
890 case 0: // Rounded, default
892 pNew
.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_ROUND
));
897 pNew
.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_NONE
));
902 pNew
.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_MITER
));
907 pNew
.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL
));
914 pOld
= GetOldItem( *rAttrs
, XATTR_LINEJOINT
);
916 if(!pOld
|| !(*static_cast<const XLineJointItem
*>(pOld
) == *pNew
))
918 rAttrs
->Put( *pNew
);
925 nPos
= m_pLBCapStyle
->GetSelectEntryPos();
926 if( LISTBOX_ENTRY_NOTFOUND
!= nPos
&& m_pLBCapStyle
->IsValueChangedFromSaved() )
928 boost::scoped_ptr
<XLineCapItem
> pNew
;
932 case 0: // Butt (=Flat), default
934 pNew
.reset(new XLineCapItem(com::sun::star::drawing::LineCap_BUTT
));
939 pNew
.reset(new XLineCapItem(com::sun::star::drawing::LineCap_ROUND
));
944 pNew
.reset(new XLineCapItem(com::sun::star::drawing::LineCap_SQUARE
));
951 pOld
= GetOldItem( *rAttrs
, XATTR_LINECAP
);
953 if(!pOld
|| !(*static_cast<const XLineCapItem
*>(pOld
) == *pNew
))
955 rAttrs
->Put( *pNew
);
961 if(nSymbolType
!=SVX_SYMBOLTYPE_UNKNOWN
|| bNewSize
)
963 // Was set by selection or the size is different
964 SvxSizeItem
aSItem(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE
),aSymbolSize
);
965 const SfxPoolItem
* pSOld
= GetOldItem( *rAttrs
, rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE
) );
966 bNewSize
= pSOld
? *static_cast<const SvxSizeItem
*>(pSOld
) != aSItem
: bNewSize
;
973 SfxInt32Item
aTItem(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE
),nSymbolType
);
974 const SfxPoolItem
* pTOld
= GetOldItem( *rAttrs
, rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE
) );
975 bool bNewType
= pTOld
== NULL
|| *static_cast<const SfxInt32Item
*>(pTOld
) != aTItem
;
976 if(bNewType
&& nSymbolType
==SVX_SYMBOLTYPE_UNKNOWN
)
977 bNewType
=false; // a small fix, type wasn't set -> don't create a type item after all!
984 if(nSymbolType
!=SVX_SYMBOLTYPE_NONE
)
986 SvxBrushItem
aBItem(aSymbolGraphic
,GPOS_MM
,rAttrs
->GetPool()->GetWhich(SID_ATTR_BRUSH
));
987 const SfxPoolItem
* pBOld
= GetOldItem( *rAttrs
, rAttrs
->GetPool()->GetWhich(SID_ATTR_BRUSH
) );
989 pBOld
== NULL
|| *static_cast<const SvxBrushItem
*>(pBOld
) != aBItem
;
997 rAttrs
->Put (CntUInt16Item(SID_PAGE_TYPE
,nPageType
));
1003 bool SvxLineTabPage::FillXLSet_Impl()
1007 if( m_pLbLineStyle
->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND
)
1009 rXLSet
.Put( XLineStyleItem( drawing::LineStyle_NONE
) );
1011 else if( m_pLbLineStyle
->IsEntryPosSelected( 0 ) )
1012 rXLSet
.Put( XLineStyleItem( drawing::LineStyle_NONE
) );
1013 else if( m_pLbLineStyle
->IsEntryPosSelected( 1 ) )
1014 rXLSet
.Put( XLineStyleItem( drawing::LineStyle_SOLID
) );
1017 rXLSet
.Put( XLineStyleItem( drawing::LineStyle_DASH
) );
1019 nPos
= m_pLbLineStyle
->GetSelectEntryPos();
1020 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1022 rXLSet
.Put( XLineDashItem( m_pLbLineStyle
->GetSelectEntry(),
1023 pDashList
->GetDash( nPos
- 2 )->GetDash() ) );
1027 nPos
= m_pLbStartStyle
->GetSelectEntryPos();
1028 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1031 rXLSet
.Put( XLineStartItem() );
1033 rXLSet
.Put( XLineStartItem( m_pLbStartStyle
->GetSelectEntry(),
1034 pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ) );
1036 nPos
= m_pLbEndStyle
->GetSelectEntryPos();
1037 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
1040 rXLSet
.Put( XLineEndItem() );
1042 rXLSet
.Put( XLineEndItem( m_pLbEndStyle
->GetSelectEntry(),
1043 pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ) );
1047 nPos
= m_pLBEdgeStyle
->GetSelectEntryPos();
1048 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
1052 case 0: // Rounded, default
1054 rXLSet
.Put(XLineJointItem(com::sun::star::drawing::LineJoint_ROUND
));
1059 rXLSet
.Put(XLineJointItem(com::sun::star::drawing::LineJoint_NONE
));
1064 rXLSet
.Put(XLineJointItem(com::sun::star::drawing::LineJoint_MITER
));
1069 rXLSet
.Put(XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL
));
1076 nPos
= m_pLBCapStyle
->GetSelectEntryPos();
1077 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
1081 case 0: // Butt (=Flat), default
1083 rXLSet
.Put(XLineCapItem(com::sun::star::drawing::LineCap_BUTT
));
1088 rXLSet
.Put(XLineCapItem(com::sun::star::drawing::LineCap_ROUND
));
1093 rXLSet
.Put(XLineCapItem(com::sun::star::drawing::LineCap_SQUARE
));
1099 rXLSet
.Put( XLineStartWidthItem( GetCoreValue( *m_pMtrStartWidth
, ePoolUnit
) ) );
1100 rXLSet
.Put( XLineEndWidthItem( GetCoreValue( *m_pMtrEndWidth
, ePoolUnit
) ) );
1102 rXLSet
.Put( XLineWidthItem( GetCoreValue( *m_pMtrLineWidth
, ePoolUnit
) ) );
1103 rXLSet
.Put( XLineColorItem( m_pLbColor
->GetSelectEntry(), m_pLbColor
->GetSelectEntryColor() ) );
1105 // Centered line end
1106 if( m_pTsbCenterStart
->GetState() == TRISTATE_TRUE
)
1107 rXLSet
.Put( XLineStartCenterItem( true ) );
1108 else if( m_pTsbCenterStart
->GetState() == TRISTATE_FALSE
)
1109 rXLSet
.Put( XLineStartCenterItem( false ) );
1111 if( m_pTsbCenterEnd
->GetState() == TRISTATE_TRUE
)
1112 rXLSet
.Put( XLineEndCenterItem( true ) );
1113 else if( m_pTsbCenterEnd
->GetState() == TRISTATE_FALSE
)
1114 rXLSet
.Put( XLineEndCenterItem( false ) );
1117 sal_uInt16 nVal
= (sal_uInt16
)m_pMtrTransparent
->GetValue();
1118 rXLSet
.Put( XLineTransparenceItem( nVal
) );
1121 m_pCtlPreview
->SetLineAttributes(aXLineAttr
.GetItemSet());
1128 void SvxLineTabPage::Reset( const SfxItemSet
* rAttrs
)
1130 drawing::LineStyle eXLS
; // drawing::LineStyle_NONE, drawing::LineStyle_SOLID, drawing::LineStyle_DASH
1133 const SfxPoolItem
*pPoolItem
;
1134 long nSymType
=SVX_SYMBOLTYPE_UNKNOWN
;
1135 bool bPrevSym
=false;
1137 bool bIgnoreGraphic
=false;
1138 bool bIgnoreSize
=false;
1139 if(rAttrs
->GetItemState(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE
),true,&pPoolItem
) == SfxItemState::SET
)
1141 nSymType
=static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue();
1144 if(nSymType
== SVX_SYMBOLTYPE_AUTO
)
1146 aSymbolGraphic
=aAutoSymbolGraphic
;
1147 aSymbolSize
=aSymbolLastSize
=aAutoSymbolGraphic
.GetPrefSize();
1150 else if(nSymType
== SVX_SYMBOLTYPE_NONE
)
1153 bIgnoreGraphic
=true;
1156 else if(nSymType
>= 0)
1158 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
1159 pVDev
->SetMapMode(MapMode(MAP_100TH_MM
));
1161 boost::scoped_ptr
<SdrModel
> pModel(new SdrModel
);
1162 pModel
->GetItemPool().FreezeIdRanges();
1163 SdrPage
* pPage
= new SdrPage( *pModel
, false );
1164 pPage
->SetSize(Size(1000,1000));
1165 pModel
->InsertPage( pPage
, 0 );
1167 boost::scoped_ptr
<SdrView
> pView(new SdrView( pModel
.get(), pVDev
));
1168 pView
->hideMarkHandles();
1169 pView
->ShowSdrPage(pPage
);
1170 SdrObject
*pObj
=NULL
;
1171 size_t nSymTmp
= static_cast<size_t>(nSymType
);
1174 if(pSymbolList
->GetObjCount())
1176 nSymTmp
%= pSymbolList
->GetObjCount(); // Treat list as cyclic!
1177 pObj
=pSymbolList
->GetObj(nSymTmp
);
1183 pObj
->SetMergedItemSet(*pSymbolAttr
);
1187 pObj
->SetMergedItemSet(rOutAttrs
);
1190 pPage
->NbcInsertObject(pObj
);
1192 // Generate invisible square to give all symbol types a
1193 // bitmap size, which is independent from specific glyph
1194 SdrObject
*pInvisibleSquare
=pSymbolList
->GetObj(0);
1195 pInvisibleSquare
=pInvisibleSquare
->Clone();
1196 pPage
->NbcInsertObject(pInvisibleSquare
);
1197 pInvisibleSquare
->SetMergedItem(XFillTransparenceItem(100));
1198 pInvisibleSquare
->SetMergedItem(XLineTransparenceItem(100));
1201 GDIMetaFile
aMeta(pView
->GetMarkedObjMetaFile());
1203 aSymbolGraphic
=Graphic(aMeta
);
1204 aSymbolSize
=pObj
->GetSnapRect().GetSize();
1205 aSymbolGraphic
.SetPrefSize(pInvisibleSquare
->GetSnapRect().GetSize());
1206 aSymbolGraphic
.SetPrefMapMode(MAP_100TH_MM
);
1209 bIgnoreGraphic
=true;
1212 pInvisibleSquare
=pPage
->RemoveObject(1);
1213 SdrObject::Free( pInvisibleSquare
);
1214 pObj
=pPage
->RemoveObject(0);
1215 SdrObject::Free( pObj
);
1221 if(rAttrs
->GetItemState(rAttrs
->GetPool()->GetWhich(SID_ATTR_BRUSH
),true,&pPoolItem
) == SfxItemState::SET
)
1223 const Graphic
* pGraphic
= static_cast<const SvxBrushItem
*>(pPoolItem
)->GetGraphic();
1228 aSymbolGraphic
=*pGraphic
;
1232 aSymbolSize
=OutputDevice::LogicToLogic( pGraphic
->GetPrefSize(),
1233 pGraphic
->GetPrefMapMode(),
1240 if(rAttrs
->GetItemState(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE
),true,&pPoolItem
) == SfxItemState::SET
)
1242 aSymbolSize
= static_cast<const SvxSizeItem
*>(pPoolItem
)->GetSize();
1245 m_pGridIconSize
->Enable(bEnable
);
1249 SetMetricValue(*m_pSymbolWidthMF
, aSymbolSize
.Width(), ePoolUnit
);
1250 SetMetricValue(*m_pSymbolHeightMF
, aSymbolSize
.Height(),ePoolUnit
);
1251 m_pCtlPreview
->SetSymbol(&aSymbolGraphic
,aSymbolSize
);
1252 aSymbolLastSize
=aSymbolSize
;
1255 if( rAttrs
->GetItemState( XATTR_LINESTYLE
) != SfxItemState::DONTCARE
)
1257 eXLS
= (drawing::LineStyle
) static_cast<const XLineStyleItem
&>( rAttrs
->Get( XATTR_LINESTYLE
) ).GetValue();
1261 case drawing::LineStyle_NONE
:
1262 m_pLbLineStyle
->SelectEntryPos( 0 );
1264 case drawing::LineStyle_SOLID
:
1265 m_pLbLineStyle
->SelectEntryPos( 1 );
1268 case drawing::LineStyle_DASH
:
1269 m_pLbLineStyle
->SetNoSelection();
1270 m_pLbLineStyle
->SelectEntry( static_cast<const XLineDashItem
&>( rAttrs
->Get( XATTR_LINEDASH
) ).GetName() );
1279 m_pLbLineStyle
->SetNoSelection();
1283 if( rAttrs
->GetItemState( XATTR_LINEWIDTH
) != SfxItemState::DONTCARE
)
1285 SetMetricValue( *m_pMtrLineWidth
, static_cast<const XLineWidthItem
&>( rAttrs
->Get( XATTR_LINEWIDTH
) ).GetValue(), ePoolUnit
);
1288 m_pMtrLineWidth
->SetText( "" );
1291 m_pLbColor
->SetNoSelection();
1293 if ( rAttrs
->GetItemState( XATTR_LINECOLOR
) != SfxItemState::DONTCARE
)
1295 Color aCol
= static_cast<const XLineColorItem
&>( rAttrs
->Get( XATTR_LINECOLOR
) ).GetColorValue();
1296 m_pLbColor
->SelectEntry( aCol
);
1297 if( m_pLbColor
->GetSelectEntryCount() == 0 )
1299 m_pLbColor
->InsertEntry( aCol
, OUString() );
1300 m_pLbColor
->SelectEntry( aCol
);
1305 if( bObjSelected
&& rAttrs
->GetItemState( XATTR_LINESTART
) == SfxItemState::DEFAULT
)
1307 m_pLbStartStyle
->Disable();
1309 else if( rAttrs
->GetItemState( XATTR_LINESTART
) != SfxItemState::DONTCARE
)
1311 // #86265# select entry using list and polygon, not string
1312 bool bSelected(false);
1313 const basegfx::B2DPolyPolygon
& rItemPolygon
= static_cast<const XLineStartItem
&>(rAttrs
->Get(XATTR_LINESTART
)).GetLineStartValue();
1315 for(sal_Int32
a(0);!bSelected
&& a
< pLineEndList
->Count(); a
++)
1317 XLineEndEntry
* pEntry
= pLineEndList
->GetLineEnd(a
);
1318 const basegfx::B2DPolyPolygon
& rEntryPolygon
= pEntry
->GetLineEnd();
1320 if(rItemPolygon
== rEntryPolygon
)
1322 // select this entry
1323 m_pLbStartStyle
->SelectEntryPos(a
+ 1);
1329 m_pLbStartStyle
->SelectEntryPos( 0 );
1333 m_pLbStartStyle
->SetNoSelection();
1337 if( bObjSelected
&& rAttrs
->GetItemState( XATTR_LINEEND
) == SfxItemState::DEFAULT
)
1339 m_pLbEndStyle
->Disable();
1341 else if( rAttrs
->GetItemState( XATTR_LINEEND
) != SfxItemState::DONTCARE
)
1343 // #86265# select entry using list and polygon, not string
1344 bool bSelected(false);
1345 const basegfx::B2DPolyPolygon
& rItemPolygon
= static_cast<const XLineEndItem
&>(rAttrs
->Get(XATTR_LINEEND
)).GetLineEndValue();
1347 for(sal_Int32
a(0);!bSelected
&& a
< pLineEndList
->Count(); a
++)
1349 XLineEndEntry
* pEntry
= pLineEndList
->GetLineEnd(a
);
1350 const basegfx::B2DPolyPolygon
& rEntryPolygon
= pEntry
->GetLineEnd();
1352 if(rItemPolygon
== rEntryPolygon
)
1354 // select this entry
1355 m_pLbEndStyle
->SelectEntryPos(a
+ 1);
1361 m_pLbEndStyle
->SelectEntryPos( 0 );
1365 m_pLbEndStyle
->SetNoSelection();
1368 // Line start strength
1369 if( bObjSelected
&& rAttrs
->GetItemState( XATTR_LINESTARTWIDTH
) == SfxItemState::DEFAULT
)
1371 m_pMtrStartWidth
->Disable();
1373 else if( rAttrs
->GetItemState( XATTR_LINESTARTWIDTH
) != SfxItemState::DONTCARE
)
1375 SetMetricValue( *m_pMtrStartWidth
,
1376 static_cast<const XLineStartWidthItem
&>( rAttrs
->Get( XATTR_LINESTARTWIDTH
) ).GetValue(),
1380 m_pMtrStartWidth
->SetText( "" );
1382 // Line end strength
1383 if( bObjSelected
&& rAttrs
->GetItemState( XATTR_LINEENDWIDTH
) == SfxItemState::DEFAULT
)
1385 m_pMtrEndWidth
->Disable();
1387 else if( rAttrs
->GetItemState( XATTR_LINEENDWIDTH
) != SfxItemState::DONTCARE
)
1389 SetMetricValue( *m_pMtrEndWidth
,
1390 static_cast<const XLineEndWidthItem
&>( rAttrs
->Get( XATTR_LINEENDWIDTH
) ).GetValue(),
1394 m_pMtrEndWidth
->SetText( "" );
1396 // Centered line end (start)
1397 if( bObjSelected
&& rAttrs
->GetItemState( XATTR_LINESTARTCENTER
) == SfxItemState::DEFAULT
)
1399 m_pTsbCenterStart
->Disable();
1401 else if( rAttrs
->GetItemState( XATTR_LINESTARTCENTER
) != SfxItemState::DONTCARE
)
1403 m_pTsbCenterStart
->EnableTriState( false );
1405 if( static_cast<const XLineStartCenterItem
&>( rAttrs
->Get( XATTR_LINESTARTCENTER
) ).GetValue() )
1406 m_pTsbCenterStart
->SetState( TRISTATE_TRUE
);
1408 m_pTsbCenterStart
->SetState( TRISTATE_FALSE
);
1412 m_pTsbCenterStart
->SetState( TRISTATE_INDET
);
1415 // Centered line end (end)
1416 if( bObjSelected
&& rAttrs
->GetItemState( XATTR_LINEENDCENTER
) == SfxItemState::DEFAULT
)
1418 m_pTsbCenterEnd
->Disable();
1420 else if( rAttrs
->GetItemState( XATTR_LINEENDCENTER
) != SfxItemState::DONTCARE
)
1422 m_pTsbCenterEnd
->EnableTriState( false );
1424 if( static_cast<const XLineEndCenterItem
&>( rAttrs
->Get( XATTR_LINEENDCENTER
) ).GetValue() )
1425 m_pTsbCenterEnd
->SetState( TRISTATE_TRUE
);
1427 m_pTsbCenterEnd
->SetState( TRISTATE_FALSE
);
1431 m_pTsbCenterEnd
->SetState( TRISTATE_INDET
);
1435 if( rAttrs
->GetItemState( XATTR_LINETRANSPARENCE
) != SfxItemState::DONTCARE
)
1437 sal_uInt16 nTransp
= static_cast<const XLineTransparenceItem
&>( rAttrs
->Get( XATTR_LINETRANSPARENCE
) ).GetValue();
1438 m_pMtrTransparent
->SetValue( nTransp
);
1439 ChangeTransparentHdl_Impl( NULL
);
1442 m_pMtrTransparent
->SetText( "" );
1444 if( !m_pLbStartStyle
->IsEnabled() &&
1445 !m_pLbEndStyle
->IsEnabled() &&
1446 !m_pMtrStartWidth
->IsEnabled() &&
1447 !m_pMtrEndWidth
->IsEnabled() &&
1448 !m_pTsbCenterStart
->IsEnabled()&&
1449 !m_pTsbCenterEnd
->IsEnabled() )
1451 m_pCbxSynchronize
->Disable();
1452 m_pFlLineEnds
->Disable();
1456 // We get the value from the INI file now
1457 OUString aStr
= GetUserData();
1458 m_pCbxSynchronize
->Check( aStr
.toInt32() != 0 );
1461 if(bObjSelected
&& SfxItemState::DEFAULT
== rAttrs
->GetItemState(XATTR_LINEJOINT
))
1463 // maFTEdgeStyle.Disable();
1464 m_pLBEdgeStyle
->Disable();
1466 else if(SfxItemState::DONTCARE
!= rAttrs
->GetItemState(XATTR_LINEJOINT
))
1468 const com::sun::star::drawing::LineJoint eLineJoint
= static_cast<const XLineJointItem
&>(rAttrs
->Get(XATTR_LINEJOINT
)).GetValue();
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 case com::sun::star::drawing::LineJoint_ROUND
: m_pLBEdgeStyle
->SelectEntryPos(0); break;
1475 case com::sun::star::drawing::LineJoint_NONE
: m_pLBEdgeStyle
->SelectEntryPos(1); break;
1476 case com::sun::star::drawing::LineJoint_MITER
: m_pLBEdgeStyle
->SelectEntryPos(2); break;
1477 case com::sun::star::drawing::LineJoint_BEVEL
: m_pLBEdgeStyle
->SelectEntryPos(3); break;
1482 m_pLBEdgeStyle
->SetNoSelection();
1486 if(bObjSelected
&& SfxItemState::DEFAULT
== rAttrs
->GetItemState(XATTR_LINECAP
))
1488 // maFTCapStyle.Disable();
1489 m_pLBCapStyle
->Disable();
1491 else if(SfxItemState::DONTCARE
!= rAttrs
->GetItemState(XATTR_LINECAP
))
1493 const com::sun::star::drawing::LineCap
eLineCap(static_cast<const XLineCapItem
&>(rAttrs
->Get(XATTR_LINECAP
)).GetValue());
1497 case com::sun::star::drawing::LineCap_ROUND
: m_pLBCapStyle
->SelectEntryPos(1); break;
1498 case com::sun::star::drawing::LineCap_SQUARE
: m_pLBCapStyle
->SelectEntryPos(2); break;
1499 default /*com::sun::star::drawing::LineCap_BUTT*/: m_pLBCapStyle
->SelectEntryPos(0); break;
1504 m_pLBCapStyle
->SetNoSelection();
1508 m_pLbLineStyle
->SaveValue();
1509 m_pMtrLineWidth
->SaveValue();
1510 m_pLbColor
->SaveValue();
1511 m_pLbStartStyle
->SaveValue();
1512 m_pLbEndStyle
->SaveValue();
1513 m_pMtrStartWidth
->SaveValue();
1514 m_pMtrEndWidth
->SaveValue();
1515 m_pTsbCenterStart
->SaveValue();
1516 m_pTsbCenterEnd
->SaveValue();
1517 m_pMtrTransparent
->SaveValue();
1520 m_pLBEdgeStyle
->SaveValue();
1523 m_pLBCapStyle
->SaveValue();
1525 ClickInvisibleHdl_Impl( this );
1527 ChangePreviewHdl_Impl( NULL
);
1532 VclPtr
<SfxTabPage
> SvxLineTabPage::Create( vcl::Window
* pWindow
,
1533 const SfxItemSet
* rAttrs
)
1535 return VclPtr
<SvxLineTabPage
>::Create( pWindow
, *rAttrs
);
1540 IMPL_LINK( SvxLineTabPage
, ChangePreviewHdl_Impl
, void *, pCntrl
)
1542 if(pCntrl
== m_pMtrLineWidth
)
1544 // Line width and start end width
1545 sal_Int32 nNewLineWidth
= GetCoreValue( *m_pMtrLineWidth
, ePoolUnit
);
1546 if(nActLineWidth
== -1)
1548 // Don't initialize yet, get the start value
1549 const SfxPoolItem
* pOld
= GetOldItem( rXLSet
, XATTR_LINEWIDTH
);
1550 sal_Int32 nStartLineWidth
= 0;
1552 nStartLineWidth
= static_cast<const XLineWidthItem
*>(pOld
)->GetValue();
1553 nActLineWidth
= nStartLineWidth
;
1556 if(nActLineWidth
!= nNewLineWidth
)
1558 // Adapt start/end width
1559 sal_Int32 nValAct
= GetCoreValue( *m_pMtrStartWidth
, ePoolUnit
);
1560 sal_Int32 nValNew
= nValAct
+ (((nNewLineWidth
- nActLineWidth
) * 15) / 10);
1563 SetMetricValue( *m_pMtrStartWidth
, nValNew
, ePoolUnit
);
1565 nValAct
= GetCoreValue( *m_pMtrEndWidth
, ePoolUnit
);
1566 nValNew
= nValAct
+ (((nNewLineWidth
- nActLineWidth
) * 15) / 10);
1569 SetMetricValue( *m_pMtrEndWidth
, nValNew
, ePoolUnit
);
1572 // Remember current value
1573 nActLineWidth
= nNewLineWidth
;
1577 m_pCtlPreview
->Invalidate();
1579 // Make transparency accessible accordingly
1580 if( m_pLbLineStyle
->GetSelectEntryPos() == 0 ) // invisible
1582 m_pBoxTransparency
->Disable();
1586 m_pBoxTransparency
->Enable();
1589 const bool bHasLineStyle
= m_pLbLineStyle
->GetSelectEntryPos() !=0;
1590 const bool bHasLineStart
= m_pLbStartStyle
->GetSelectEntryPos() != 0;
1592 m_pBoxStart
->Enable(bHasLineStart
&& bHasLineStyle
);
1594 const bool bHasLineEnd
= m_pLbEndStyle
->GetSelectEntryPos() != 0;
1596 m_pBoxEnd
->Enable(bHasLineEnd
&& bHasLineStyle
);
1603 IMPL_LINK( SvxLineTabPage
, ChangeStartHdl_Impl
, void *, p
)
1605 if( m_pCbxSynchronize
->IsChecked() )
1607 if( p
== m_pMtrStartWidth
)
1608 m_pMtrEndWidth
->SetValue( m_pMtrStartWidth
->GetValue() );
1609 if( p
== m_pLbStartStyle
)
1610 m_pLbEndStyle
->SelectEntryPos( m_pLbStartStyle
->GetSelectEntryPos() );
1611 if( p
== m_pTsbCenterStart
)
1612 m_pTsbCenterEnd
->SetState( m_pTsbCenterStart
->GetState() );
1615 ChangePreviewHdl_Impl( this );
1623 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeEdgeStyleHdl_Impl
)
1625 ChangePreviewHdl_Impl( this );
1633 IMPL_LINK_NOARG( SvxLineTabPage
, ChangeCapStyleHdl_Impl
)
1635 ChangePreviewHdl_Impl( this );
1641 IMPL_LINK_NOARG(SvxLineTabPage
, ClickInvisibleHdl_Impl
)
1643 if( m_pLbLineStyle
->GetSelectEntryPos() == 0 ) // invisible
1646 m_pBoxColor
->Disable();
1648 m_pBoxWidth
->Disable();
1650 if( m_pFlLineEnds
->IsEnabled() )
1652 m_pBoxStart
->Disable();
1653 m_pBoxArrowStyles
->Disable();
1657 m_pGridEdgeCaps
->Disable();
1662 m_pBoxColor
->Enable();
1663 m_pBoxWidth
->Enable();
1665 if( m_pFlLineEnds
->IsEnabled() )
1667 m_pBoxArrowStyles
->Enable();
1669 m_pGridEdgeCaps
->Enable();
1672 ChangePreviewHdl_Impl( NULL
);
1679 IMPL_LINK( SvxLineTabPage
, ChangeEndHdl_Impl
, void *, p
)
1681 if( m_pCbxSynchronize
->IsChecked() )
1683 if( p
== m_pMtrEndWidth
)
1684 m_pMtrStartWidth
->SetValue( m_pMtrEndWidth
->GetValue() );
1685 if( p
== m_pLbEndStyle
)
1686 m_pLbStartStyle
->SelectEntryPos( m_pLbEndStyle
->GetSelectEntryPos() );
1687 if( p
== m_pTsbCenterEnd
)
1688 m_pTsbCenterStart
->SetState( m_pTsbCenterEnd
->GetState() );
1691 ChangePreviewHdl_Impl( this );
1698 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeTransparentHdl_Impl
)
1700 sal_uInt16 nVal
= (sal_uInt16
)m_pMtrTransparent
->GetValue();
1701 XLineTransparenceItem
aItem( nVal
);
1703 rXLSet
.Put( XLineTransparenceItem( aItem
) );
1708 m_pCtlPreview
->Invalidate();
1715 void SvxLineTabPage::PointChanged( vcl::Window
*, RECT_POINT eRcPt
)
1722 void SvxLineTabPage::FillUserData()
1724 // Write the synched value to the INI file
1725 // OUString aStrUserData = OUString::valueOf( (sal_Int32) m_pCbxSynchronize->IsChecked() );
1726 OUString aStrUserData
= OUString::boolean(m_pCbxSynchronize
->IsChecked());
1727 SetUserData( aStrUserData
);
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 IMPL_LINK( SvxLineTabPage
, MenuCreateHdl_Impl
, MenuButton
*, pButton
)
1736 InitSymbols(pButton
);
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 IMPL_LINK(SvxLineTabPage
, GraphicArrivedHdl_Impl
, SvxBrushItem
*, pItem
)
1744 PopupMenu
* pPopup
= m_pSymbolMB
->GetPopupMenu()->GetPopupMenu( MN_GALLERY
);
1746 SvxBmpItemInfo
* pBmpInfo
= 0;
1747 for ( size_t i
= 0; i
< aGrfBrushItems
.size(); i
++ )
1749 SvxBmpItemInfo
* pInfo
= aGrfBrushItems
[ i
];
1750 if( pInfo
->pBrushItem
== pItem
)
1752 pBmpInfo
= pInfo
; break;
1757 const Graphic
* pGraphic
= pItem
->GetGraphic();
1760 Bitmap
aBitmap(pGraphic
->GetBitmap());
1761 Size
aSize(aBitmap
.GetSizePixel());
1762 if(aSize
.Width() > MAX_BMP_WIDTH
|| aSize
.Height() > MAX_BMP_HEIGHT
)
1764 bool bWidth
= aSize
.Width() > aSize
.Height();
1765 double nScale
= bWidth
?
1766 (double)MAX_BMP_WIDTH
/ (double)aSize
.Width():
1767 (double)MAX_BMP_HEIGHT
/ (double)aSize
.Height();
1768 aBitmap
.Scale(nScale
, nScale
);
1770 Image
aImage(aBitmap
);
1771 pPopup
->SetItemImage( pBmpInfo
->nItemId
, aImage
);
1778 // #58425# Symbols on a list (e.g. StarChart)
1779 // Handler for menu button
1780 IMPL_LINK_TYPED( SvxLineTabPage
, GraphicHdl_Impl
, MenuButton
*, pButton
, void )
1782 SymbolSelected(pButton
);
1785 IMPL_LINK( SvxLineTabPage
, SizeHdl_Impl
, MetricField
*, pField
)
1788 bool bWidth
= pField
== m_pSymbolWidthMF
;
1789 bLastWidthModified
= bWidth
;
1790 bool bRatio
= m_pSymbolRatioCB
->IsChecked();
1791 long nWidthVal
= static_cast<long>(m_pSymbolWidthMF
->Denormalize(m_pSymbolWidthMF
->GetValue(FUNIT_100TH_MM
)));
1792 long nHeightVal
= static_cast<long>(m_pSymbolHeightMF
->Denormalize(m_pSymbolHeightMF
->GetValue(FUNIT_100TH_MM
)));
1793 nWidthVal
= OutputDevice::LogicToLogic(nWidthVal
,MAP_100TH_MM
,(MapUnit
)ePoolUnit
);
1794 nHeightVal
= OutputDevice::LogicToLogic(nHeightVal
,MAP_100TH_MM
,(MapUnit
)ePoolUnit
);
1795 aSymbolSize
= Size(nWidthVal
,nHeightVal
);
1796 double fSizeRatio
= (double)1;
1800 if (aSymbolLastSize
.Height() && aSymbolLastSize
.Width())
1801 fSizeRatio
= (double)aSymbolLastSize
.Width() / aSymbolLastSize
.Height();
1804 //Size aSymbolSize(aSymbolLastSize);
1808 long nDelta
= nWidthVal
- aSymbolLastSize
.Width();
1809 aSymbolSize
.Width() = nWidthVal
;
1812 aSymbolSize
.Height() = aSymbolLastSize
.Height() + (long)((double)nDelta
/ fSizeRatio
);
1813 aSymbolSize
.Height() = OutputDevice::LogicToLogic( aSymbolSize
.Height(),(MapUnit
)ePoolUnit
, MAP_100TH_MM
);
1814 m_pSymbolHeightMF
->SetUserValue(m_pSymbolHeightMF
->Normalize(aSymbolSize
.Height()), FUNIT_100TH_MM
);
1819 long nDelta
= nHeightVal
- aSymbolLastSize
.Height();
1820 aSymbolSize
.Height() = nHeightVal
;
1823 aSymbolSize
.Width() = aSymbolLastSize
.Width() + (long)((double)nDelta
* fSizeRatio
);
1824 aSymbolSize
.Width() = OutputDevice::LogicToLogic( aSymbolSize
.Width(), (MapUnit
)ePoolUnit
, MAP_100TH_MM
);
1825 m_pSymbolWidthMF
->SetUserValue(m_pSymbolWidthMF
->Normalize(aSymbolSize
.Width()), FUNIT_100TH_MM
);
1828 m_pCtlPreview
->ResizeSymbol(aSymbolSize
);
1829 aSymbolLastSize
=aSymbolSize
;
1832 IMPL_LINK( SvxLineTabPage
, RatioHdl_Impl
, CheckBox
*, pBox
)
1834 if (pBox
->IsChecked())
1836 if (bLastWidthModified
)
1837 SizeHdl_Impl(m_pSymbolWidthMF
);
1839 SizeHdl_Impl(m_pSymbolHeightMF
);
1845 void SvxLineTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
1847 SvxTabPage::DataChanged( rDCEvt
);
1849 if ( (rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) && (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
1855 void SvxLineTabPage::PageCreated(const SfxAllItemSet
& aSet
)
1857 SFX_ITEMSET_ARG (&aSet
,pColorListItem
,SvxColorListItem
,SID_COLOR_TABLE
,false);
1858 SFX_ITEMSET_ARG (&aSet
,pDashListItem
,SvxDashListItem
,SID_DASH_LIST
,false);
1859 SFX_ITEMSET_ARG (&aSet
,pLineEndListItem
,SvxLineEndListItem
,SID_LINEEND_LIST
,false);
1860 SFX_ITEMSET_ARG (&aSet
,pPageTypeItem
,SfxUInt16Item
,SID_PAGE_TYPE
,false);
1861 SFX_ITEMSET_ARG (&aSet
,pDlgTypeItem
,SfxUInt16Item
,SID_DLG_TYPE
,false);
1862 SFX_ITEMSET_ARG (&aSet
,pSdrObjListItem
,OfaPtrItem
,SID_OBJECT_LIST
,false);
1863 SFX_ITEMSET_ARG (&aSet
,pSymbolAttrItem
,SfxTabDialogItem
,SID_ATTR_SET
,false);
1864 SFX_ITEMSET_ARG (&aSet
,pGraphicItem
,SvxGraphicItem
,SID_GRAPHIC
,false);
1867 SetColorList(pColorListItem
->GetColorList());
1869 SetDashList(pDashListItem
->GetDashList());
1870 if (pLineEndListItem
)
1871 SetLineEndList(pLineEndListItem
->GetLineEndList());
1873 SetPageType(pPageTypeItem
->GetValue());
1875 SetDlgType(pDlgTypeItem
->GetValue());
1878 if(pSdrObjListItem
) //symbols
1880 ShowSymbolControls(true);
1881 pSymbolList
= static_cast<SdrObjList
*>(pSdrObjListItem
->GetValue());
1882 if (pSymbolAttrItem
)
1883 pSymbolAttr
= new SfxItemSet(pSymbolAttrItem
->GetItemSet());
1885 aAutoSymbolGraphic
= pGraphicItem
->GetGraphic();
1889 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */