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 .
21 #include <editeng/sizeitem.hxx>
22 #include <osl/file.hxx>
23 #include <tools/urlobj.hxx>
25 #include <strings.hrc>
26 #include <svx/colorbox.hxx>
27 #include <svx/dlgctrl.hxx>
28 #include <svx/xlineit0.hxx>
29 #include <svx/xlinjoit.hxx>
30 #include <svx/xlncapit.hxx>
31 #include <svx/xlndsit.hxx>
32 #include <svx/xlnwtit.hxx>
33 #include <svx/xlnstwit.hxx>
34 #include <svx/xlnedwit.hxx>
35 #include <svx/xlnclit.hxx>
36 #include <svx/xlnstit.hxx>
37 #include <svx/xlnedit.hxx>
38 #include <svx/xlnstcit.hxx>
39 #include <svx/xlnedcit.hxx>
42 #include <svx/tabline.hxx>
43 #include <svx/xtable.hxx>
44 #include <svx/drawitem.hxx>
45 #include <cuitabline.hxx>
46 #include <dialmgr.hxx>
47 #include <svx/dlgutil.hxx>
48 #include <svx/svxgraphicitem.hxx>
49 #include <svx/ofaitem.hxx>
50 #include <svx/svdobj.hxx>
51 #include <svx/svdpage.hxx>
52 #include <svx/svdview.hxx>
53 #include <svx/svdmodel.hxx>
54 #include <svx/xlntrit.hxx>
55 #include <svx/xfltrit.hxx>
56 #include <editeng/numitem.hxx>
57 #include <editeng/brushitem.hxx>
58 #include <svx/gallery.hxx>
59 #include <sfx2/opengrf.hxx>
60 #include <svx/dialmgr.hxx>
61 #include <svx/svxids.hrc>
62 #include <svx/strings.hrc>
63 #include <cuitabarea.hxx>
64 #include <svtools/unitconv.hxx>
65 #include <comphelper/lok.hxx>
67 #define MAX_BMP_WIDTH 16
68 #define MAX_BMP_HEIGHT 16
70 using namespace com::sun::star
;
72 // static ----------------------------------------------------------------
74 const WhichRangesContainer
SvxLineTabPage::pLineRanges(svl::Items
<
75 XATTR_LINETRANSPARENCE
, XATTR_LINETRANSPARENCE
,
76 SID_ATTR_LINE_STYLE
, SID_ATTR_LINE_ENDCENTER
79 SvxLineTabPage::SvxLineTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rInAttrs
)
80 : SfxTabPage(pPage
, pController
, "cui/ui/linetabpage.ui", "LineTabPage", &rInAttrs
)
81 , m_pSymbolList(nullptr)
83 , m_nSymbolType(SVX_SYMBOLTYPE_UNKNOWN
) // unknown respectively unchanged
84 , m_bLastWidthModified(false)
85 , m_aSymbolLastSize(Size(0,0))
87 , m_rOutAttrs(rInAttrs
)
88 , m_bObjSelected(false)
89 , m_aXLineAttr(rInAttrs
.GetPool())
90 , m_rXLSet(m_aXLineAttr
.GetItemSet())
91 , m_pnLineEndListState(nullptr)
92 , m_pnDashListState(nullptr)
93 , m_pnColorListState(nullptr)
94 , m_nPageType(PageType::Area
)
96 , m_pPosDashLb(nullptr)
97 , m_pPosLineEndLb(nullptr)
98 , m_xBoxColor(m_xBuilder
->weld_widget("boxCOLOR"))
99 , m_xLbLineStyle(new SvxLineLB(m_xBuilder
->weld_combo_box("LB_LINE_STYLE")))
100 , m_xLbColor(new ColorListBox(m_xBuilder
->weld_menu_button("LB_COLOR"),
101 [this]{ return GetDialogController()->getDialog(); }))
102 , m_xBoxWidth(m_xBuilder
->weld_widget("boxWIDTH"))
103 , m_xMtrLineWidth(m_xBuilder
->weld_metric_spin_button("MTR_FLD_LINE_WIDTH", FieldUnit::CM
))
104 , m_xBoxTransparency(m_xBuilder
->weld_widget("boxTRANSPARENCY"))
105 , m_xMtrTransparent(m_xBuilder
->weld_metric_spin_button("MTR_LINE_TRANSPARENT", FieldUnit::PERCENT
))
106 , m_xFlLineEnds(m_xBuilder
->weld_widget("FL_LINE_ENDS"))
107 , m_xBoxArrowStyles(m_xBuilder
->weld_widget("boxARROW_STYLES"))
108 , m_xLbStartStyle(new SvxLineEndLB(m_xBuilder
->weld_combo_box("LB_START_STYLE")))
109 , m_xBoxStart(m_xBuilder
->weld_widget("boxSTART"))
110 , m_xMtrStartWidth(m_xBuilder
->weld_metric_spin_button("MTR_FLD_START_WIDTH", FieldUnit::CM
))
111 , m_xTsbCenterStart(m_xBuilder
->weld_check_button("TSB_CENTER_START"))
112 , m_xBoxEnd(m_xBuilder
->weld_widget("boxEND"))
113 , m_xLbEndStyle(new SvxLineEndLB(m_xBuilder
->weld_combo_box("LB_END_STYLE")))
114 , m_xMtrEndWidth(m_xBuilder
->weld_metric_spin_button("MTR_FLD_END_WIDTH", FieldUnit::CM
))
115 , m_xTsbCenterEnd(m_xBuilder
->weld_check_button("TSB_CENTER_END"))
116 , m_xCbxSynchronize(m_xBuilder
->weld_check_button("CBX_SYNCHRONIZE"))
117 , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder
, "CTL_PREVIEW", m_aCtlPreview
))
118 , m_xFLEdgeStyle(m_xBuilder
->weld_widget("FL_EDGE_STYLE"))
119 , m_xGridEdgeCaps(m_xBuilder
->weld_widget("gridEDGE_CAPS"))
120 , m_xLBEdgeStyle(m_xBuilder
->weld_combo_box("LB_EDGE_STYLE"))
121 , m_xLBCapStyle(m_xBuilder
->weld_combo_box("LB_CAP_STYLE")) // LineCaps
122 , m_xFlSymbol(m_xBuilder
->weld_widget("FL_SYMBOL_FORMAT")) //#58425# Symbols on a line (e.g. StarChart)
123 , m_xGridIconSize(m_xBuilder
->weld_widget("gridICON_SIZE"))
124 , m_xSymbolMB(m_xBuilder
->weld_menu_button("MB_SYMBOL_BITMAP"))
125 , m_xSymbolWidthMF(m_xBuilder
->weld_metric_spin_button("MF_SYMBOL_WIDTH", FieldUnit::CM
))
126 , m_xSymbolHeightMF(m_xBuilder
->weld_metric_spin_button("MF_SYMBOL_HEIGHT", FieldUnit::CM
))
127 , m_xSymbolRatioCB(m_xBuilder
->weld_check_button("CB_SYMBOL_RATIO"))
129 // This Page requires ExchangeSupport
130 SetExchangeSupport();
133 FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
139 eFUnit
= FieldUnit::MM
;
140 [[fallthrough
]]; // we now have mm
142 m_xMtrLineWidth
->set_increments(50, 500, FieldUnit::NONE
);
143 m_xMtrStartWidth
->set_increments(50, 500, FieldUnit::NONE
);
144 m_xMtrEndWidth
->set_increments(50, 500, FieldUnit::NONE
);
147 case FieldUnit::INCH
:
148 m_xMtrLineWidth
->set_increments(2, 20, FieldUnit::NONE
);
149 m_xMtrStartWidth
->set_increments(2, 20, FieldUnit::NONE
);
150 m_xMtrEndWidth
->set_increments(2, 20, FieldUnit::NONE
);
152 default: ;// prevent warning
154 SetFieldUnit( *m_xMtrLineWidth
, eFUnit
);
155 SetFieldUnit( *m_xMtrStartWidth
, eFUnit
);
156 SetFieldUnit( *m_xMtrEndWidth
, eFUnit
);
158 // determine PoolUnit
159 SfxItemPool
* pPool
= m_rOutAttrs
.GetPool();
160 DBG_ASSERT( pPool
, "Where is the pool?" );
161 m_ePoolUnit
= pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
163 m_xLbLineStyle
->connect_changed(LINK(this, SvxLineTabPage
, ClickInvisibleHdl_Impl
));
164 m_xLbColor
->SetSelectHdl( LINK( this, SvxLineTabPage
, ChangePreviewListBoxHdl_Impl
) );
165 m_xMtrLineWidth
->connect_value_changed(LINK(this, SvxLineTabPage
, ChangePreviewModifyHdl_Impl
));
166 m_xMtrTransparent
->connect_value_changed(LINK( this, SvxLineTabPage
, ChangeTransparentHdl_Impl
));
168 m_xLbStartStyle
->connect_changed(LINK(this, SvxLineTabPage
, ChangeStartListBoxHdl_Impl
));
169 m_xLbEndStyle
->connect_changed(LINK(this, SvxLineTabPage
, ChangeEndListBoxHdl_Impl
));
170 m_xMtrStartWidth
->connect_value_changed(LINK(this, SvxLineTabPage
, ChangeStartModifyHdl_Impl
));
171 m_xMtrEndWidth
->connect_value_changed(LINK( this, SvxLineTabPage
, ChangeEndModifyHdl_Impl
));
172 m_xTsbCenterStart
->connect_toggled(LINK(this, SvxLineTabPage
, ChangeStartClickHdl_Impl
));
173 m_xTsbCenterEnd
->connect_toggled(LINK(this, SvxLineTabPage
, ChangeEndClickHdl_Impl
));
175 Link
<weld::ComboBox
&,void> aEdgeStyle
= LINK(this, SvxLineTabPage
, ChangeEdgeStyleHdl_Impl
);
176 m_xLBEdgeStyle
->connect_changed(aEdgeStyle
);
179 Link
<weld::ComboBox
&,void> aCapStyle
= LINK(this, SvxLineTabPage
, ChangeCapStyleHdl_Impl
);
180 m_xLBCapStyle
->connect_changed(aCapStyle
);
182 // Symbols on a line (eg star charts), MB-handler set
183 m_xSymbolMB
->connect_selected(LINK(this, SvxLineTabPage
, GraphicHdl_Impl
));
184 m_xSymbolMB
->connect_toggled(LINK(this, SvxLineTabPage
, MenuCreateHdl_Impl
));
185 m_xSymbolWidthMF
->connect_value_changed(LINK(this, SvxLineTabPage
, SizeHdl_Impl
));
186 m_xSymbolHeightMF
->connect_value_changed(LINK(this, SvxLineTabPage
, SizeHdl_Impl
));
187 m_xSymbolRatioCB
->connect_toggled(LINK(this, SvxLineTabPage
, RatioHdl_Impl
));
189 m_xSymbolRatioCB
->set_active(true);
190 ShowSymbolControls(false);
192 m_nActLineWidth
= -1;
195 void SvxLineTabPage::ShowSymbolControls(bool bOn
)
197 // Symbols on a line (e.g. StarCharts), symbol-enable controls
200 m_xFlSymbol
->set_visible(bOn
);
201 m_aCtlPreview
.ShowSymbol(bOn
);
204 SvxLineTabPage::~SvxLineTabPage()
206 m_xCtlPreview
.reset();
207 m_xLbEndStyle
.reset();
208 m_xLbStartStyle
.reset();
210 m_xLbLineStyle
.reset();
211 m_aGalleryBrushItems
.clear();
212 m_aSymbolBrushItems
.clear();
215 void SvxLineTabPage::Construct()
220 void SvxLineTabPage::FillListboxes()
223 auto nOldSelect
= m_xLbLineStyle
->get_active();
224 // aLbLineStyle.FillStyles();
225 m_xLbLineStyle
->Fill( m_pDashList
);
226 m_xLbLineStyle
->set_active( nOldSelect
);
229 OUString
sNone( comphelper::LibreOfficeKit::isActive() ? SvxResId( RID_SVXSTR_INVISIBLE
)
230 : SvxResId( RID_SVXSTR_NONE
) );
231 nOldSelect
= m_xLbStartStyle
->get_active();
232 m_xLbStartStyle
->clear();
233 m_xLbStartStyle
->append_text(sNone
);
234 m_xLbStartStyle
->Fill(m_pLineEndList
);
235 m_xLbStartStyle
->set_active(nOldSelect
);
236 nOldSelect
= m_xLbEndStyle
->get_active();
237 m_xLbEndStyle
->clear();
238 m_xLbEndStyle
->append_text(sNone
);
239 m_xLbEndStyle
->Fill(m_pLineEndList
, false);
240 m_xLbEndStyle
->set_active(nOldSelect
);
243 void SvxLineTabPage::ActivatePage( const SfxItemSet
& rSet
)
245 const SfxUInt16Item
* pPageTypeItem
= rSet
.GetItem
<SfxUInt16Item
>(SID_PAGE_TYPE
, false);
247 SetPageType(static_cast<PageType
>(pPageTypeItem
->GetValue()));
248 if( m_nDlgType
== 0 && m_pDashList
.is() )
254 if( ( *m_pnDashListState
& ChangeType::MODIFIED
) ||
255 ( *m_pnDashListState
& ChangeType::CHANGED
) )
257 if( *m_pnDashListState
& ChangeType::CHANGED
)
258 m_pDashList
= static_cast<SvxLineTabDialog
*>(GetDialogController() )->GetNewDashList();
260 *m_pnDashListState
= ChangeType::NONE
;
263 nPos
= m_xLbLineStyle
->get_active();
265 m_xLbLineStyle
->clear();
266 m_xLbLineStyle
->append_text(SvxResId(RID_SVXSTR_INVISIBLE
));
267 m_xLbLineStyle
->append_text(SvxResId(RID_SVXSTR_SOLID
));
268 m_xLbLineStyle
->Fill(m_pDashList
);
269 nCount
= m_xLbLineStyle
->get_count();
272 ; // This case should never occur
273 else if( nCount
<= nPos
)
274 m_xLbLineStyle
->set_active(0);
276 m_xLbLineStyle
->set_active(nPos
);
279 INetURLObject
aDashURL( m_pDashList
->GetPath() );
281 aDashURL
.Append( m_pDashList
->GetName() );
282 DBG_ASSERT( aDashURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
284 if( ( *m_pnLineEndListState
& ChangeType::MODIFIED
) || ( *m_pnLineEndListState
& ChangeType::CHANGED
) )
286 if( *m_pnLineEndListState
& ChangeType::CHANGED
)
287 m_pLineEndList
= static_cast<SvxLineTabDialog
*>(GetDialogController())->GetNewLineEndList();
289 *m_pnLineEndListState
= ChangeType::NONE
;
291 nPos
= m_xLbLineStyle
->get_active();
292 OUString
sNone( comphelper::LibreOfficeKit::isActive() ? SvxResId( RID_SVXSTR_INVISIBLE
)
293 : SvxResId( RID_SVXSTR_NONE
) );
295 m_xLbStartStyle
->clear();
296 m_xLbStartStyle
->append_text(sNone
);
298 m_xLbStartStyle
->Fill( m_pLineEndList
);
299 nCount
= m_xLbStartStyle
->get_count();
301 ; // This case should never occur
302 else if( nCount
<= nPos
)
303 m_xLbStartStyle
->set_active(0);
305 m_xLbStartStyle
->set_active(nPos
);
307 m_xLbEndStyle
->clear();
308 m_xLbEndStyle
->append_text(sNone
);
310 m_xLbEndStyle
->Fill( m_pLineEndList
, false );
311 nCount
= m_xLbEndStyle
->get_count();
314 ; // This case should never occur
315 else if( nCount
<= nPos
)
316 m_xLbEndStyle
->set_active(0);
318 m_xLbEndStyle
->set_active(nPos
);
320 INetURLObject
aLineURL( m_pLineEndList
->GetPath() );
322 aLineURL
.Append( m_pLineEndList
->GetName() );
323 DBG_ASSERT( aLineURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
324 // Evaluate if another TabPage set another fill type
325 if( m_xLbLineStyle
->get_active() != 0 )
327 if( m_nPageType
== PageType::Hatch
) // 1
329 m_xLbLineStyle
->set_active(*m_pPosDashLb
+ 2); // +2 due to SOLID and INVISIBLE
330 ChangePreviewHdl_Impl( nullptr );
332 if( m_nPageType
== PageType::Bitmap
)
334 m_xLbStartStyle
->set_active(*m_pPosLineEndLb
+ 1);// +1 due to SOLID
335 m_xLbEndStyle
->set_active(*m_pPosLineEndLb
+ 1);// +1 due to SOLID
336 ChangePreviewHdl_Impl( nullptr );
341 if( *m_pnColorListState
!= ChangeType::NONE
)
343 ChangePreviewHdl_Impl( nullptr );
346 m_nPageType
= PageType::Area
;
348 // Page does not yet exist in the ctor, that's why we do it here!
350 else if (m_nDlgType
== 1101) // nNoArrowNoShadowDlg from chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
352 m_xFlLineEnds
->hide();
353 m_xFLEdgeStyle
->hide();
358 DeactivateRC
SvxLineTabPage::DeactivatePage( SfxItemSet
* _pSet
)
360 if( m_nDlgType
== 0 ) // Line dialog
362 m_nPageType
= PageType::Gradient
; // possibly for extensions
363 *m_pPosDashLb
= m_xLbLineStyle
->get_active() - 2;// First entry SOLID!!!
364 sal_Int32 nPos
= m_xLbStartStyle
->get_active();
367 *m_pPosLineEndLb
= nPos
;
371 FillItemSet( _pSet
);
373 return DeactivateRC::LeavePage
;
377 bool SvxLineTabPage::FillItemSet( SfxItemSet
* rAttrs
)
379 const SfxPoolItem
* pOld
= nullptr;
381 bool bModified
= false;
383 // To prevent modifications to the list, we do not set other page's items.
384 if( m_nDlgType
!= 0 || m_nPageType
!= PageType::Hatch
)
386 nPos
= m_xLbLineStyle
->get_active();
388 m_xLbLineStyle
->get_value_changed_from_saved() )
390 std::unique_ptr
<XLineStyleItem
> pStyleItem
;
393 pStyleItem
.reset(new XLineStyleItem( drawing::LineStyle_NONE
));
395 pStyleItem
.reset(new XLineStyleItem( drawing::LineStyle_SOLID
));
398 pStyleItem
.reset(new XLineStyleItem( drawing::LineStyle_DASH
));
400 // For added security
401 if( m_pDashList
->Count() > static_cast<tools::Long
>( nPos
- 2 ) )
403 XLineDashItem
aDashItem( m_xLbLineStyle
->get_active_text(),
404 m_pDashList
->GetDash( nPos
- 2 )->GetDash() );
405 pOld
= GetOldItem( *rAttrs
, XATTR_LINEDASH
);
406 if ( !pOld
|| !( *static_cast<const XLineDashItem
*>(pOld
) == aDashItem
) )
408 rAttrs
->Put( aDashItem
);
413 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTYLE
);
414 if ( !pOld
|| !( *static_cast<const XLineStyleItem
*>(pOld
) == *pStyleItem
) )
416 rAttrs
->Put( std::move(pStyleItem
) );
422 // GetSavedValue() returns OUString!
423 if( m_xMtrLineWidth
->get_value_changed_from_saved() )
425 XLineWidthItem
aItem( GetCoreValue( *m_xMtrLineWidth
, m_ePoolUnit
) );
426 pOld
= GetOldItem( *rAttrs
, XATTR_LINEWIDTH
);
427 if ( !pOld
|| !( *static_cast<const XLineWidthItem
*>(pOld
) == aItem
) )
429 rAttrs
->Put( aItem
);
434 if( m_xMtrStartWidth
->get_value_changed_from_saved() )
436 XLineStartWidthItem
aItem( GetCoreValue( *m_xMtrStartWidth
, m_ePoolUnit
) );
437 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTARTWIDTH
);
438 if ( !pOld
|| !( *static_cast<const XLineStartWidthItem
*>(pOld
) == aItem
) )
440 rAttrs
->Put( aItem
);
445 if( m_xMtrEndWidth
->get_value_changed_from_saved() )
447 XLineEndWidthItem
aItem( GetCoreValue( *m_xMtrEndWidth
, m_ePoolUnit
) );
448 pOld
= GetOldItem( *rAttrs
, XATTR_LINEENDWIDTH
);
449 if ( !pOld
|| !( *static_cast<const XLineEndWidthItem
*>(pOld
) == aItem
) )
451 rAttrs
->Put( aItem
);
457 if (m_xLbColor
->IsValueChangedFromSaved())
459 NamedColor aColor
= m_xLbColor
->GetSelectedEntry();
460 XLineColorItem
aItem(aColor
.m_aName
, aColor
.m_aColor
);
461 pOld
= GetOldItem( *rAttrs
, XATTR_LINECOLOR
);
462 if ( !pOld
|| !( *static_cast<const XLineColorItem
*>(pOld
) == aItem
) )
464 rAttrs
->Put( aItem
);
469 if( m_nDlgType
!= 0 || m_nPageType
!= PageType::Bitmap
)
472 nPos
= m_xLbStartStyle
->get_active();
473 if( nPos
!= -1 && m_xLbStartStyle
->get_value_changed_from_saved() )
475 std::unique_ptr
<XLineStartItem
> pItem
;
477 pItem
.reset(new XLineStartItem());
478 else if( m_pLineEndList
->Count() > static_cast<tools::Long
>( nPos
- 1 ) )
479 pItem
.reset(new XLineStartItem( m_xLbStartStyle
->get_active_text(), m_pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ));
480 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTART
);
481 if( pItem
&& ( !pOld
|| *pOld
!= *pItem
) )
483 rAttrs
->Put( std::move(pItem
) );
488 nPos
= m_xLbEndStyle
->get_active();
489 if( nPos
!= -1 && m_xLbEndStyle
->get_value_changed_from_saved() )
491 std::unique_ptr
<XLineEndItem
> pItem
;
493 pItem
.reset(new XLineEndItem());
494 else if( m_pLineEndList
->Count() > static_cast<tools::Long
>( nPos
- 1 ) )
495 pItem
.reset(new XLineEndItem( m_xLbEndStyle
->get_active_text(), m_pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ));
496 pOld
= GetOldItem( *rAttrs
, XATTR_LINEEND
);
498 ( !pOld
|| !( *static_cast<const XLineEndItem
*>(pOld
) == *pItem
) ) )
500 rAttrs
->Put( std::move(pItem
) );
507 TriState eState
= m_xTsbCenterStart
->get_state();
508 if( m_xTsbCenterStart
->get_state_changed_from_saved() )
510 XLineStartCenterItem
aItem( eState
!= TRISTATE_FALSE
);
511 pOld
= GetOldItem( *rAttrs
, XATTR_LINESTARTCENTER
);
512 if ( !pOld
|| !( *static_cast<const XLineStartCenterItem
*>(pOld
) == aItem
) )
514 rAttrs
->Put( aItem
);
518 eState
= m_xTsbCenterEnd
->get_state();
519 if( m_xTsbCenterEnd
->get_state_changed_from_saved() )
521 XLineEndCenterItem
aItem( eState
!= TRISTATE_FALSE
);
522 pOld
= GetOldItem( *rAttrs
, XATTR_LINEENDCENTER
);
523 if ( !pOld
|| !( *static_cast<const XLineEndCenterItem
*>(pOld
) == aItem
) )
525 rAttrs
->Put( aItem
);
531 sal_uInt16 nVal
= m_xMtrTransparent
->get_value(FieldUnit::PERCENT
);
532 if( m_xMtrTransparent
->get_value_changed_from_saved() )
534 XLineTransparenceItem
aItem( nVal
);
535 pOld
= GetOldItem( *rAttrs
, XATTR_LINETRANSPARENCE
);
536 if ( !pOld
|| !( *static_cast<const XLineTransparenceItem
*>(pOld
) == aItem
) )
538 rAttrs
->Put( aItem
);
543 nPos
= m_xLBEdgeStyle
->get_active();
544 if (nPos
!= -1 && m_xLBEdgeStyle
->get_value_changed_from_saved())
546 std::unique_ptr
<XLineJointItem
> pNew
;
550 case 0: // Rounded, default
552 pNew
.reset(new XLineJointItem(css::drawing::LineJoint_ROUND
));
557 pNew
.reset(new XLineJointItem(css::drawing::LineJoint_NONE
));
562 pNew
.reset(new XLineJointItem(css::drawing::LineJoint_MITER
));
567 pNew
.reset(new XLineJointItem(css::drawing::LineJoint_BEVEL
));
574 pOld
= GetOldItem( *rAttrs
, XATTR_LINEJOINT
);
576 if(!pOld
|| !(*static_cast<const XLineJointItem
*>(pOld
) == *pNew
))
578 rAttrs
->Put( std::move(pNew
) );
585 nPos
= m_xLBCapStyle
->get_active();
586 if (nPos
!= -1 && m_xLBCapStyle
->get_value_changed_from_saved())
588 std::unique_ptr
<XLineCapItem
> pNew
;
592 case 0: // Butt (=Flat), default
594 pNew
.reset(new XLineCapItem(css::drawing::LineCap_BUTT
));
599 pNew
.reset(new XLineCapItem(css::drawing::LineCap_ROUND
));
604 pNew
.reset(new XLineCapItem(css::drawing::LineCap_SQUARE
));
611 pOld
= GetOldItem( *rAttrs
, XATTR_LINECAP
);
613 if(!pOld
|| !(*static_cast<const XLineCapItem
*>(pOld
) == *pNew
))
615 rAttrs
->Put( std::move(pNew
) );
621 if(m_nSymbolType
!=SVX_SYMBOLTYPE_UNKNOWN
|| m_bNewSize
)
623 // Was set by selection or the size is different
624 SvxSizeItem
aSItem(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE
),m_aSymbolSize
);
625 const SfxPoolItem
* pSOld
= GetOldItem( *rAttrs
, rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE
) );
626 m_bNewSize
= pSOld
? *static_cast<const SvxSizeItem
*>(pSOld
) != aSItem
: m_bNewSize
;
633 SfxInt32Item
aTItem(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE
),m_nSymbolType
);
634 const SfxPoolItem
* pTOld
= GetOldItem( *rAttrs
, rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE
) );
635 bool bNewType
= pTOld
== nullptr || *static_cast<const SfxInt32Item
*>(pTOld
) != aTItem
;
636 if(bNewType
&& m_nSymbolType
==SVX_SYMBOLTYPE_UNKNOWN
)
637 bNewType
=false; // a small fix, type wasn't set -> don't create a type item after all!
644 if(m_nSymbolType
!=SVX_SYMBOLTYPE_NONE
)
646 SvxBrushItem
aBItem(m_aSymbolGraphic
,GPOS_MM
,rAttrs
->GetPool()->GetWhich(SID_ATTR_BRUSH
));
647 const SfxPoolItem
* pBOld
= GetOldItem( *rAttrs
, rAttrs
->GetPool()->GetWhich(SID_ATTR_BRUSH
) );
649 pBOld
== nullptr || *static_cast<const SvxBrushItem
*>(pBOld
) != aBItem
;
657 rAttrs
->Put (CntUInt16Item(SID_PAGE_TYPE
, static_cast<sal_uInt16
>(m_nPageType
)));
662 void SvxLineTabPage::FillXLSet_Impl()
666 if (m_xLbLineStyle
->get_active() == -1)
668 m_rXLSet
.Put( XLineStyleItem( drawing::LineStyle_NONE
) );
670 else if (m_xLbLineStyle
->get_active() == 0)
671 m_rXLSet
.Put( XLineStyleItem( drawing::LineStyle_NONE
) );
672 else if (m_xLbLineStyle
->get_active() == 1)
673 m_rXLSet
.Put( XLineStyleItem( drawing::LineStyle_SOLID
) );
676 m_rXLSet
.Put( XLineStyleItem( drawing::LineStyle_DASH
) );
678 nPos
= m_xLbLineStyle
->get_active();
681 m_rXLSet
.Put( XLineDashItem( m_xLbLineStyle
->get_active_text(),
682 m_pDashList
->GetDash( nPos
- 2 )->GetDash() ) );
686 nPos
= m_xLbStartStyle
->get_active();
690 m_rXLSet
.Put( XLineStartItem() );
692 m_rXLSet
.Put( XLineStartItem( m_xLbStartStyle
->get_active_text(),
693 m_pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ) );
695 nPos
= m_xLbEndStyle
->get_active();
699 m_rXLSet
.Put( XLineEndItem() );
701 m_rXLSet
.Put( XLineEndItem( m_xLbEndStyle
->get_active_text(),
702 m_pLineEndList
->GetLineEnd( nPos
- 1 )->GetLineEnd() ) );
705 nPos
= m_xLBEdgeStyle
->get_active();
710 case 0: // Rounded, default
712 m_rXLSet
.Put(XLineJointItem(css::drawing::LineJoint_ROUND
));
717 m_rXLSet
.Put(XLineJointItem(css::drawing::LineJoint_NONE
));
722 m_rXLSet
.Put(XLineJointItem(css::drawing::LineJoint_MITER
));
727 m_rXLSet
.Put(XLineJointItem(css::drawing::LineJoint_BEVEL
));
734 nPos
= m_xLBCapStyle
->get_active();
739 case 0: // Butt (=Flat), default
741 m_rXLSet
.Put(XLineCapItem(css::drawing::LineCap_BUTT
));
746 m_rXLSet
.Put(XLineCapItem(css::drawing::LineCap_ROUND
));
751 m_rXLSet
.Put(XLineCapItem(css::drawing::LineCap_SQUARE
));
757 m_rXLSet
.Put( XLineStartWidthItem( GetCoreValue( *m_xMtrStartWidth
, m_ePoolUnit
) ) );
758 m_rXLSet
.Put( XLineEndWidthItem( GetCoreValue( *m_xMtrEndWidth
, m_ePoolUnit
) ) );
760 m_rXLSet
.Put( XLineWidthItem( GetCoreValue( *m_xMtrLineWidth
, m_ePoolUnit
) ) );
761 NamedColor aColor
= m_xLbColor
->GetSelectedEntry();
762 m_rXLSet
.Put(XLineColorItem(aColor
.m_aName
, aColor
.m_aColor
));
765 if( m_xTsbCenterStart
->get_state() == TRISTATE_TRUE
)
766 m_rXLSet
.Put( XLineStartCenterItem( true ) );
767 else if( m_xTsbCenterStart
->get_state() == TRISTATE_FALSE
)
768 m_rXLSet
.Put( XLineStartCenterItem( false ) );
770 if( m_xTsbCenterEnd
->get_state() == TRISTATE_TRUE
)
771 m_rXLSet
.Put( XLineEndCenterItem( true ) );
772 else if( m_xTsbCenterEnd
->get_state() == TRISTATE_FALSE
)
773 m_rXLSet
.Put( XLineEndCenterItem( false ) );
776 sal_uInt16 nVal
= m_xMtrTransparent
->get_value(FieldUnit::PERCENT
);
777 m_rXLSet
.Put( XLineTransparenceItem( nVal
) );
779 m_aCtlPreview
.SetLineAttributes(m_aXLineAttr
.GetItemSet());
783 void SvxLineTabPage::Reset( const SfxItemSet
* rAttrs
)
785 drawing::LineStyle eXLS
; // drawing::LineStyle_NONE, drawing::LineStyle_SOLID, drawing::LineStyle_DASH
788 tools::Long nSymType
=SVX_SYMBOLTYPE_UNKNOWN
;
791 bool bIgnoreGraphic
=false;
792 bool bIgnoreSize
=false;
793 if(const SfxInt32Item
* pSymbolTypeItem
= rAttrs
->GetItemIfSet(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE
)))
795 nSymType
= pSymbolTypeItem
->GetValue();
798 if(nSymType
== SVX_SYMBOLTYPE_AUTO
)
800 m_aSymbolGraphic
=m_aAutoSymbolGraphic
;
801 m_aSymbolSize
=m_aSymbolLastSize
=m_aAutoSymbolGraphic
.GetPrefSize();
804 else if(nSymType
== SVX_SYMBOLTYPE_NONE
)
810 else if(nSymType
>= 0)
812 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
813 pVDev
->SetMapMode(MapMode(MapUnit::Map100thMM
));
815 std::unique_ptr
<SdrModel
> pModel(
816 new SdrModel(nullptr, nullptr, true));
817 pModel
->GetItemPool().FreezeIdRanges();
818 rtl::Reference
<SdrPage
> pPage
= new SdrPage( *pModel
, false );
819 pPage
->SetSize(Size(1000,1000));
820 pModel
->InsertPage( pPage
.get(), 0 );
822 SdrView
aView( *pModel
, pVDev
);
823 aView
.hideMarkHandles();
824 aView
.ShowSdrPage(pPage
.get());
825 size_t nSymTmp
= static_cast<size_t>(nSymType
);
828 if(m_pSymbolList
->GetObjCount())
830 nSymTmp
%= m_pSymbolList
->GetObjCount(); // Treat list as cyclic!
831 rtl::Reference
<SdrObject
> pObj
=m_pSymbolList
->GetObj(nSymTmp
);
834 // directly clone to target SdrModel
835 pObj
= pObj
->CloneSdrObject(*pModel
);
839 pObj
->SetMergedItemSet(*m_xSymbolAttr
);
843 pObj
->SetMergedItemSet(m_rOutAttrs
);
846 pPage
->NbcInsertObject(pObj
.get());
848 // Generate invisible square to give all symbol types a
849 // bitmap size, which is independent from specific glyph
850 rtl::Reference
<SdrObject
> pInvisibleSquare(m_pSymbolList
->GetObj(0));
852 // directly clone to target SdrModel
853 pInvisibleSquare
= pInvisibleSquare
->CloneSdrObject(*pModel
);
855 pPage
->NbcInsertObject(pInvisibleSquare
.get());
856 pInvisibleSquare
->SetMergedItem(XFillTransparenceItem(100));
857 pInvisibleSquare
->SetMergedItem(XLineTransparenceItem(100));
860 GDIMetaFile
aMeta(aView
.GetMarkedObjMetaFile());
862 m_aSymbolGraphic
=Graphic(aMeta
);
863 m_aSymbolSize
=pObj
->GetSnapRect().GetSize();
864 m_aSymbolGraphic
.SetPrefSize(pInvisibleSquare
->GetSnapRect().GetSize());
865 m_aSymbolGraphic
.SetPrefMapMode(MapMode(MapUnit::Map100thMM
));
871 pPage
->RemoveObject(1);
872 pInvisibleSquare
.clear();
873 pPage
->RemoveObject(0);
880 if(const SvxBrushItem
* pBrushItem
= rAttrs
->GetItemIfSet(rAttrs
->GetPool()->GetWhich(SID_ATTR_BRUSH
)))
882 const Graphic
* pGraphic
= pBrushItem
->GetGraphic();
887 m_aSymbolGraphic
=*pGraphic
;
891 m_aSymbolSize
=OutputDevice::LogicToLogic( pGraphic
->GetPrefSize(),
892 pGraphic
->GetPrefMapMode(),
893 MapMode(MapUnit::Map100thMM
));
899 if(const SvxSizeItem
* pSymbolSizeItem
= rAttrs
->GetItemIfSet(rAttrs
->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE
)))
901 m_aSymbolSize
= pSymbolSizeItem
->GetSize();
904 m_xGridIconSize
->set_sensitive(bEnable
);
908 SetMetricValue(*m_xSymbolWidthMF
, m_aSymbolSize
.Width(), m_ePoolUnit
);
909 SetMetricValue(*m_xSymbolHeightMF
, m_aSymbolSize
.Height(),m_ePoolUnit
);
910 m_aCtlPreview
.SetSymbol(&m_aSymbolGraphic
,m_aSymbolSize
);
911 m_aSymbolLastSize
=m_aSymbolSize
;
914 if( rAttrs
->GetItemState( XATTR_LINESTYLE
) != SfxItemState::DONTCARE
)
916 eXLS
= rAttrs
->Get( XATTR_LINESTYLE
).GetValue();
920 case drawing::LineStyle_NONE
:
921 m_xLbLineStyle
->set_active(0);
923 case drawing::LineStyle_SOLID
:
924 m_xLbLineStyle
->set_active(1);
927 case drawing::LineStyle_DASH
:
928 m_xLbLineStyle
->set_active(-1);
929 m_xLbLineStyle
->set_active_text(rAttrs
->Get( XATTR_LINEDASH
).GetName());
938 m_xLbLineStyle
->set_active(-1);
942 if( rAttrs
->GetItemState( XATTR_LINEWIDTH
) != SfxItemState::DONTCARE
)
944 SetMetricValue( *m_xMtrLineWidth
, rAttrs
->Get( XATTR_LINEWIDTH
).GetValue(), m_ePoolUnit
);
947 m_xMtrLineWidth
->set_text("");
950 m_xLbColor
->SetNoSelection();
952 if ( rAttrs
->GetItemState( XATTR_LINECOLOR
) != SfxItemState::DONTCARE
)
954 Color aCol
= rAttrs
->Get( XATTR_LINECOLOR
).GetColorValue();
955 m_xLbColor
->SelectEntry( aCol
);
959 if( m_bObjSelected
&& rAttrs
->GetItemState( XATTR_LINESTART
) == SfxItemState::DEFAULT
)
961 m_xLbStartStyle
->set_sensitive(false);
963 else if( rAttrs
->GetItemState( XATTR_LINESTART
) != SfxItemState::DONTCARE
)
965 // #86265# select entry using list and polygon, not string
966 bool bSelected(false);
967 const basegfx::B2DPolyPolygon
& rItemPolygon
= rAttrs
->Get(XATTR_LINESTART
).GetLineStartValue();
969 for(tools::Long
a(0);!bSelected
&& a
< m_pLineEndList
->Count(); a
++)
971 const XLineEndEntry
* pEntry
= m_pLineEndList
->GetLineEnd(a
);
972 const basegfx::B2DPolyPolygon
& rEntryPolygon
= pEntry
->GetLineEnd();
974 if(rItemPolygon
== rEntryPolygon
)
977 m_xLbStartStyle
->set_active(a
+ 1);
983 m_xLbStartStyle
->set_active(0);
987 m_xLbStartStyle
->set_active(-1);
991 if( m_bObjSelected
&& rAttrs
->GetItemState( XATTR_LINEEND
) == SfxItemState::DEFAULT
)
993 m_xLbEndStyle
->set_sensitive(false);
995 else if( rAttrs
->GetItemState( XATTR_LINEEND
) != SfxItemState::DONTCARE
)
997 // #86265# select entry using list and polygon, not string
998 bool bSelected(false);
999 const basegfx::B2DPolyPolygon
& rItemPolygon
= rAttrs
->Get(XATTR_LINEEND
).GetLineEndValue();
1001 for(tools::Long
a(0);!bSelected
&& a
< m_pLineEndList
->Count(); a
++)
1003 const XLineEndEntry
* pEntry
= m_pLineEndList
->GetLineEnd(a
);
1004 const basegfx::B2DPolyPolygon
& rEntryPolygon
= pEntry
->GetLineEnd();
1006 if(rItemPolygon
== rEntryPolygon
)
1008 // select this entry
1009 m_xLbEndStyle
->set_active(a
+ 1);
1015 m_xLbEndStyle
->set_active(0);
1019 m_xLbEndStyle
->set_active(-1);
1022 // Line start strength
1023 if( m_bObjSelected
&& rAttrs
->GetItemState( XATTR_LINESTARTWIDTH
) == SfxItemState::DEFAULT
)
1025 m_xMtrStartWidth
->set_sensitive(false);
1027 else if( rAttrs
->GetItemState( XATTR_LINESTARTWIDTH
) != SfxItemState::DONTCARE
)
1029 SetMetricValue( *m_xMtrStartWidth
,
1030 rAttrs
->Get( XATTR_LINESTARTWIDTH
).GetValue(),
1034 m_xMtrStartWidth
->set_text( "" );
1036 // Line end strength
1037 if( m_bObjSelected
&& rAttrs
->GetItemState( XATTR_LINEENDWIDTH
) == SfxItemState::DEFAULT
)
1039 m_xMtrEndWidth
->set_sensitive(false);
1041 else if( rAttrs
->GetItemState( XATTR_LINEENDWIDTH
) != SfxItemState::DONTCARE
)
1043 SetMetricValue( *m_xMtrEndWidth
,
1044 rAttrs
->Get( XATTR_LINEENDWIDTH
).GetValue(),
1048 m_xMtrEndWidth
->set_text("");
1050 // Centered line end (start)
1051 if( m_bObjSelected
&& rAttrs
->GetItemState( XATTR_LINESTARTCENTER
) == SfxItemState::DEFAULT
)
1053 m_xTsbCenterStart
->set_sensitive(false);
1055 else if( rAttrs
->GetItemState( XATTR_LINESTARTCENTER
) != SfxItemState::DONTCARE
)
1057 if( rAttrs
->Get( XATTR_LINESTARTCENTER
).GetValue() )
1058 m_xTsbCenterStart
->set_state(TRISTATE_TRUE
);
1060 m_xTsbCenterStart
->set_state(TRISTATE_FALSE
);
1064 m_xTsbCenterStart
->set_state(TRISTATE_INDET
);
1067 // Centered line end (end)
1068 if( m_bObjSelected
&& rAttrs
->GetItemState( XATTR_LINEENDCENTER
) == SfxItemState::DEFAULT
)
1070 m_xTsbCenterEnd
->set_sensitive(false);
1072 else if( rAttrs
->GetItemState( XATTR_LINEENDCENTER
) != SfxItemState::DONTCARE
)
1074 if( rAttrs
->Get( XATTR_LINEENDCENTER
).GetValue() )
1075 m_xTsbCenterEnd
->set_state(TRISTATE_TRUE
);
1077 m_xTsbCenterEnd
->set_state(TRISTATE_FALSE
);
1081 m_xTsbCenterEnd
->set_state(TRISTATE_INDET
);
1085 if( rAttrs
->GetItemState( XATTR_LINETRANSPARENCE
) != SfxItemState::DONTCARE
)
1087 sal_uInt16 nTransp
= rAttrs
->Get( XATTR_LINETRANSPARENCE
).GetValue();
1088 m_xMtrTransparent
->set_value(nTransp
, FieldUnit::PERCENT
);
1089 ChangeTransparentHdl_Impl(*m_xMtrTransparent
);
1092 m_xMtrTransparent
->set_text( "" );
1094 if( !m_xLbStartStyle
->get_sensitive() &&
1095 !m_xLbEndStyle
->get_sensitive() &&
1096 !m_xMtrStartWidth
->get_sensitive() &&
1097 !m_xMtrEndWidth
->get_sensitive() &&
1098 !m_xTsbCenterStart
->get_sensitive()&&
1099 !m_xTsbCenterEnd
->get_sensitive() )
1101 m_xCbxSynchronize
->set_sensitive(false);
1102 m_xFlLineEnds
->set_sensitive(false);
1106 // We get the value from the INI file now
1107 OUString aStr
= GetUserData();
1108 m_xCbxSynchronize
->set_active(aStr
.toInt32() != 0);
1110 if(m_bObjSelected
&& SfxItemState::DEFAULT
== rAttrs
->GetItemState(XATTR_LINEJOINT
))
1112 // maFTEdgeStyle.set_sensitive(false);
1113 m_xLBEdgeStyle
->set_sensitive(false);
1115 else if(SfxItemState::DONTCARE
!= rAttrs
->GetItemState(XATTR_LINEJOINT
))
1117 const css::drawing::LineJoint eLineJoint
= rAttrs
->Get(XATTR_LINEJOINT
).GetValue();
1121 case css::drawing::LineJoint::LineJoint_MAKE_FIXED_SIZE
: // fallback to round, unused value
1122 case css::drawing::LineJoint_ROUND
: m_xLBEdgeStyle
->set_active(0); break;
1123 case css::drawing::LineJoint_NONE
: m_xLBEdgeStyle
->set_active(1); break;
1124 case css::drawing::LineJoint_MIDDLE
: // fallback to mitre, unused value
1125 case css::drawing::LineJoint_MITER
: m_xLBEdgeStyle
->set_active(2); break;
1126 case css::drawing::LineJoint_BEVEL
: m_xLBEdgeStyle
->set_active(3); break;
1131 m_xLBEdgeStyle
->set_active(-1);
1135 if(m_bObjSelected
&& SfxItemState::DEFAULT
== rAttrs
->GetItemState(XATTR_LINECAP
))
1137 m_xLBCapStyle
->set_sensitive(false);
1139 else if(SfxItemState::DONTCARE
!= rAttrs
->GetItemState(XATTR_LINECAP
))
1141 const css::drawing::LineCap
eLineCap(rAttrs
->Get(XATTR_LINECAP
).GetValue());
1145 case css::drawing::LineCap_ROUND
: m_xLBCapStyle
->set_active(1); break;
1146 case css::drawing::LineCap_SQUARE
: m_xLBCapStyle
->set_active(2); break;
1147 default /*css::drawing::LineCap_BUTT*/: m_xLBCapStyle
->set_active(0); break;
1152 m_xLBCapStyle
->set_active(-1);
1156 m_xLbLineStyle
->save_value();
1157 m_xMtrLineWidth
->save_value();
1158 m_xLbColor
->SaveValue();
1159 m_xLbStartStyle
->save_value();
1160 m_xLbEndStyle
->save_value();
1161 m_xMtrStartWidth
->save_value();
1162 m_xMtrEndWidth
->save_value();
1163 m_xTsbCenterStart
->save_state();
1164 m_xTsbCenterEnd
->save_state();
1165 m_xMtrTransparent
->save_value();
1167 m_xLBEdgeStyle
->save_value();
1170 m_xLBCapStyle
->save_value();
1172 ClickInvisibleHdl_Impl();
1174 ChangePreviewHdl_Impl( nullptr );
1177 std::unique_ptr
<SfxTabPage
> SvxLineTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
1178 const SfxItemSet
* rAttrs
)
1180 return std::make_unique
<SvxLineTabPage
>(pPage
, pController
, *rAttrs
);
1183 IMPL_LINK_NOARG(SvxLineTabPage
, ChangePreviewListBoxHdl_Impl
, ColorListBox
&, void)
1185 ChangePreviewHdl_Impl(nullptr);
1188 IMPL_LINK(SvxLineTabPage
, ChangePreviewModifyHdl_Impl
, weld::MetricSpinButton
&, rEdit
, void)
1190 ChangePreviewHdl_Impl(&rEdit
);
1193 void SvxLineTabPage::ChangePreviewHdl_Impl(const weld::MetricSpinButton
* pCntrl
)
1195 if (pCntrl
== m_xMtrLineWidth
.get())
1197 // Line width and start end width
1198 sal_Int32 nNewLineWidth
= GetCoreValue( *m_xMtrLineWidth
, m_ePoolUnit
);
1199 if(m_nActLineWidth
== -1)
1201 // Don't initialize yet, get the start value
1202 const SfxPoolItem
* pOld
= GetOldItem( m_rXLSet
, XATTR_LINEWIDTH
);
1203 sal_Int32 nStartLineWidth
= 0;
1205 nStartLineWidth
= static_cast<const XLineWidthItem
*>(pOld
)->GetValue();
1206 m_nActLineWidth
= nStartLineWidth
;
1209 if(m_nActLineWidth
!= nNewLineWidth
)
1211 // Adapt start/end width
1212 sal_Int32 nValAct
= GetCoreValue( *m_xMtrStartWidth
, m_ePoolUnit
);
1213 sal_Int32 nValNew
= nValAct
+ (((nNewLineWidth
- m_nActLineWidth
) * 15) / 10);
1216 SetMetricValue( *m_xMtrStartWidth
, nValNew
, m_ePoolUnit
);
1218 nValAct
= GetCoreValue( *m_xMtrEndWidth
, m_ePoolUnit
);
1219 nValNew
= nValAct
+ (((nNewLineWidth
- m_nActLineWidth
) * 15) / 10);
1222 SetMetricValue( *m_xMtrEndWidth
, nValNew
, m_ePoolUnit
);
1225 // Remember current value
1226 m_nActLineWidth
= nNewLineWidth
;
1230 m_aCtlPreview
.Invalidate();
1232 // Make transparency accessible accordingly
1233 if( m_xLbLineStyle
->get_active() == 0 ) // invisible
1235 m_xBoxTransparency
->set_sensitive(false);
1239 m_xBoxTransparency
->set_sensitive(true);
1242 const bool bHasLineStyle
= m_xLbLineStyle
->get_active() !=0;
1243 const bool bHasLineStart
= m_xLbStartStyle
->get_active() != 0;
1245 m_xBoxStart
->set_sensitive(bHasLineStart
&& bHasLineStyle
);
1247 const bool bHasLineEnd
= m_xLbEndStyle
->get_active() != 0;
1249 m_xBoxEnd
->set_sensitive(bHasLineEnd
&& bHasLineStyle
);
1252 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeStartClickHdl_Impl
, weld::Toggleable
&, void)
1254 if (m_xCbxSynchronize
->get_active())
1255 m_xTsbCenterEnd
->set_state(m_xTsbCenterStart
->get_state());
1256 ChangePreviewHdl_Impl(nullptr);
1259 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeStartListBoxHdl_Impl
, weld::ComboBox
&, void)
1261 if (m_xCbxSynchronize
->get_active())
1262 m_xLbEndStyle
->set_active(m_xLbStartStyle
->get_active());
1264 ChangePreviewHdl_Impl(nullptr);
1267 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeStartModifyHdl_Impl
, weld::MetricSpinButton
&, void)
1269 if (m_xCbxSynchronize
->get_active())
1270 m_xMtrEndWidth
->set_value(m_xMtrStartWidth
->get_value(FieldUnit::NONE
), FieldUnit::NONE
);
1272 ChangePreviewHdl_Impl(nullptr);
1275 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeEdgeStyleHdl_Impl
, weld::ComboBox
&, void)
1277 ChangePreviewHdl_Impl( nullptr );
1281 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeCapStyleHdl_Impl
, weld::ComboBox
&, void)
1283 ChangePreviewHdl_Impl( nullptr );
1286 IMPL_LINK_NOARG(SvxLineTabPage
, ClickInvisibleHdl_Impl
, weld::ComboBox
&, void)
1288 ClickInvisibleHdl_Impl();
1291 void SvxLineTabPage::ClickInvisibleHdl_Impl()
1293 if( m_xLbLineStyle
->get_active() == 0 ) // invisible
1296 m_xBoxColor
->set_sensitive(false);
1298 m_xBoxWidth
->set_sensitive(false);
1300 if( m_xFlLineEnds
->get_sensitive() )
1302 m_xBoxStart
->set_sensitive(false);
1303 m_xBoxArrowStyles
->set_sensitive(false);
1304 m_xGridEdgeCaps
->set_sensitive(false);
1309 // set cap style associated to the line style
1310 sal_Int32 nPos
= m_xLbLineStyle
->get_active();
1311 if( nPos
> 1 && m_pDashList
->Count() > static_cast<tools::Long
>( nPos
- 2 ) )
1313 css::drawing::DashStyle eStyle
=
1314 m_pDashList
->GetDash( nPos
- 2 )->GetDash().GetDashStyle();
1315 if ( eStyle
== drawing::DashStyle_RECT
|| eStyle
== drawing::DashStyle_RECTRELATIVE
)
1316 m_xLBCapStyle
->set_active(0);
1318 m_xLBCapStyle
->set_active(1);
1321 m_xBoxColor
->set_sensitive(true);
1322 m_xBoxWidth
->set_sensitive(true);
1324 if (m_xFlLineEnds
->get_sensitive())
1326 m_xBoxArrowStyles
->set_sensitive(true);
1327 m_xGridEdgeCaps
->set_sensitive(true);
1330 ChangePreviewHdl_Impl( nullptr );
1333 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeEndClickHdl_Impl
, weld::Toggleable
&, void)
1335 if (m_xCbxSynchronize
->get_active())
1336 m_xTsbCenterStart
->set_state(m_xTsbCenterEnd
->get_state());
1338 ChangePreviewHdl_Impl(nullptr);
1341 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeEndListBoxHdl_Impl
, weld::ComboBox
&, void)
1343 if (m_xCbxSynchronize
->get_active())
1344 m_xLbStartStyle
->set_active(m_xLbEndStyle
->get_active());
1346 ChangePreviewHdl_Impl(nullptr);
1349 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeEndModifyHdl_Impl
, weld::MetricSpinButton
&, void)
1351 if (m_xCbxSynchronize
->get_active())
1352 m_xMtrStartWidth
->set_value(m_xMtrEndWidth
->get_value(FieldUnit::NONE
), FieldUnit::NONE
);
1354 ChangePreviewHdl_Impl(nullptr);
1357 IMPL_LINK_NOARG(SvxLineTabPage
, ChangeTransparentHdl_Impl
, weld::MetricSpinButton
&, void)
1359 sal_uInt16 nVal
= m_xMtrTransparent
->get_value(FieldUnit::PERCENT
);
1361 m_rXLSet
.Put(XLineTransparenceItem(nVal
));
1365 m_aCtlPreview
.Invalidate();
1368 void SvxLineTabPage::FillUserData()
1370 // Write the synched value to the INI file
1371 OUString aStrUserData
= OUString::boolean(m_xCbxSynchronize
->get_active());
1372 SetUserData( aStrUserData
);
1375 // #58425# Symbols on a list (e.g. StarChart)
1376 // Handler for the symbol selection's popup menu (NumMenueButton)
1377 // The following link originates from SvxNumOptionsTabPage
1378 IMPL_LINK_NOARG(SvxLineTabPage
, MenuCreateHdl_Impl
, weld::Toggleable
&, void)
1380 ScopedVclPtrInstance
< VirtualDevice
> pVD
;
1383 if (!m_xGalleryMenu
)
1385 m_xGalleryMenu
= m_xBuilder
->weld_menu("gallerysubmenu");
1386 weld::WaitObject
aWait(GetFrameWeld());
1387 // Get gallery entries
1388 GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS
, m_aGrfNames
);
1391 for (auto const& grfName
: m_aGrfNames
)
1393 const OUString
*pUIName
= &grfName
;
1395 // Convert URL encodings to UI characters (e.g. %20 for spaces)
1396 OUString aPhysicalName
;
1397 if (osl::FileBase::getSystemPathFromFileURL(grfName
, aPhysicalName
)
1398 == osl::FileBase::E_None
)
1400 pUIName
= &aPhysicalName
;
1403 SvxBmpItemInfo
* pInfo
= new SvxBmpItemInfo
;
1404 pInfo
->pBrushItem
.reset(new SvxBrushItem(grfName
, "", GPOS_AREA
, SID_ATTR_BRUSH
));
1405 pInfo
->sItemId
= "gallery" + OUString::number(i
);
1406 m_aGalleryBrushItems
.emplace_back(pInfo
);
1407 const Graphic
* pGraphic
= pInfo
->pBrushItem
->GetGraphic();
1411 BitmapEx
aBitmap(pGraphic
->GetBitmapEx());
1412 Size
aSize(aBitmap
.GetSizePixel());
1413 if(aSize
.Width() > MAX_BMP_WIDTH
|| aSize
.Height() > MAX_BMP_HEIGHT
)
1415 bool bWidth
= aSize
.Width() > aSize
.Height();
1416 double nScale
= bWidth
?
1417 double(MAX_BMP_WIDTH
) / static_cast<double>(aSize
.Width()):
1418 double(MAX_BMP_HEIGHT
) / static_cast<double>(aSize
.Height());
1419 aBitmap
.Scale(nScale
, nScale
);
1422 pVD
->SetOutputSizePixel(aBitmap
.GetSizePixel());
1423 pVD
->DrawBitmapEx(Point(), aBitmap
);
1424 m_xGalleryMenu
->append(pInfo
->sItemId
, *pUIName
, *pVD
);
1428 m_xGalleryMenu
->append(pInfo
->sItemId
, *pUIName
);
1433 if (m_aGrfNames
.empty())
1434 m_xSymbolMB
->set_item_sensitive("gallery", false);
1437 if (m_xSymbolsMenu
|| !m_pSymbolList
)
1440 m_xSymbolsMenu
= m_xBuilder
->weld_menu("symbolssubmenu");
1441 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
1442 pVDev
->SetMapMode(MapMode(MapUnit::Map100thMM
));
1443 std::unique_ptr
<SdrModel
> pModel(
1444 new SdrModel(nullptr, nullptr, true));
1445 pModel
->GetItemPool().FreezeIdRanges();
1447 rtl::Reference
<SdrPage
> pPage
= new SdrPage( *pModel
, false );
1448 pPage
->SetSize(Size(1000,1000));
1449 pModel
->InsertPage( pPage
.get(), 0 );
1452 SdrView
aView( *pModel
, pVDev
);
1453 aView
.hideMarkHandles();
1454 aView
.ShowSdrPage(pPage
.get());
1456 // Generate invisible square to give all symbols a
1457 // bitmap size, which is independent from specific glyph
1458 rtl::Reference
<SdrObject
> pInvisibleSquare
=m_pSymbolList
->GetObj(0);
1460 // directly clone to target SdrModel
1461 pInvisibleSquare
= pInvisibleSquare
->CloneSdrObject(*pModel
);
1463 pPage
->NbcInsertObject(pInvisibleSquare
.get());
1464 pInvisibleSquare
->SetMergedItem(XFillTransparenceItem(100));
1465 pInvisibleSquare
->SetMergedItem(XLineTransparenceItem(100));
1467 for(size_t i
=0; i
< m_pSymbolList
->GetObjCount(); ++i
)
1469 rtl::Reference
<SdrObject
> pObj
=m_pSymbolList
->GetObj(i
);
1472 // directly clone to target SdrModel
1473 pObj
= pObj
->CloneSdrObject(*pModel
);
1475 m_aGrfNames
.emplace_back("");
1476 pPage
->NbcInsertObject(pObj
.get());
1479 pObj
->SetMergedItemSet(*m_xSymbolAttr
);
1483 pObj
->SetMergedItemSet(m_rOutAttrs
);
1486 BitmapEx
aBitmapEx(aView
.GetMarkedObjBitmapEx());
1487 GDIMetaFile
aMeta(aView
.GetMarkedObjMetaFile());
1489 pPage
->RemoveObject(1);
1492 SvxBmpItemInfo
* pInfo
= new SvxBmpItemInfo
;
1493 pInfo
->pBrushItem
.reset(new SvxBrushItem(Graphic(aMeta
), GPOS_AREA
, SID_ATTR_BRUSH
));
1494 pInfo
->sItemId
= "symbol" + OUString::number(i
);
1495 m_aSymbolBrushItems
.emplace_back(pInfo
);
1497 Size
aSize(aBitmapEx
.GetSizePixel());
1498 if(aSize
.Width() > MAX_BMP_WIDTH
|| aSize
.Height() > MAX_BMP_HEIGHT
)
1500 bool bWidth
= aSize
.Width() > aSize
.Height();
1501 double nScale
= bWidth
?
1502 double(MAX_BMP_WIDTH
) / static_cast<double>(aSize
.Width()):
1503 double(MAX_BMP_HEIGHT
) / static_cast<double>(aSize
.Height());
1504 aBitmapEx
.Scale(nScale
, nScale
);
1506 pVD
->SetOutputSizePixel(aBitmapEx
.GetSizePixel());
1507 pVD
->DrawBitmapEx(Point(), aBitmapEx
);
1508 m_xSymbolsMenu
->append(pInfo
->sItemId
, "", *pVD
);
1510 pPage
->RemoveObject(0);
1511 pInvisibleSquare
.clear();
1513 if (m_aGrfNames
.empty())
1514 m_xSymbolMB
->set_item_sensitive("symbols", false);
1518 // #58425# Symbols on a list (e.g. StarChart)
1519 // Handler for menu button
1520 IMPL_LINK(SvxLineTabPage
, GraphicHdl_Impl
, const OUString
&, rIdent
, void)
1522 const Graphic
* pGraphic
= nullptr;
1524 bool bResetSize
= false;
1525 bool bEnable
= true;
1526 tools::Long nPreviousSymbolType
= m_nSymbolType
;
1529 if (rIdent
.startsWith("gallery", &sNumber
))
1531 SvxBmpItemInfo
* pInfo
= m_aGalleryBrushItems
[sNumber
.toUInt32()].get();
1532 pGraphic
= pInfo
->pBrushItem
->GetGraphic();
1533 m_nSymbolType
= SVX_SYMBOLTYPE_BRUSHITEM
;
1535 else if (rIdent
.startsWith("symbol", &sNumber
))
1537 m_nSymbolType
= sNumber
.toUInt32();
1538 SvxBmpItemInfo
* pInfo
= m_aSymbolBrushItems
[m_nSymbolType
].get();
1539 pGraphic
= pInfo
->pBrushItem
->GetGraphic();
1541 else if (rIdent
== "automatic")
1543 pGraphic
=&m_aAutoSymbolGraphic
;
1544 m_aAutoSymbolGraphic
.SetPrefSize( Size(253,253) );
1545 m_nSymbolType
=SVX_SYMBOLTYPE_AUTO
;
1547 else if (rIdent
== "none")
1549 m_nSymbolType
=SVX_SYMBOLTYPE_NONE
;
1553 else if (rIdent
== "file")
1555 SvxOpenGraphicDialog
aGrfDlg(CuiResId(RID_CUISTR_EDIT_GRAPHIC
), GetFrameWeld());
1556 aGrfDlg
.EnableLink(false);
1557 aGrfDlg
.AsLink(false);
1558 if( !aGrfDlg
.Execute() )
1560 // Remember selected filters
1561 if( !aGrfDlg
.GetGraphic(aGraphic
) )
1563 m_nSymbolType
=SVX_SYMBOLTYPE_BRUSHITEM
;
1564 pGraphic
= &aGraphic
;
1574 Size aSize
= SvxNumberFormat::GetGraphicSizeMM100(pGraphic
);
1575 aSize
= OutputDevice::LogicToLogic(aSize
, MapMode(MapUnit::Map100thMM
), MapMode(m_ePoolUnit
));
1576 m_aSymbolGraphic
=*pGraphic
;
1579 m_aSymbolSize
=aSize
;
1581 else if( nPreviousSymbolType
== SVX_SYMBOLTYPE_BRUSHITEM
)
1582 { //#i31097# Data Point Symbol size changes when a different symbol is chosen(maoyg)
1583 if( m_aSymbolSize
.Width() != m_aSymbolSize
.Height() )
1585 aSize
.setWidth( static_cast<tools::Long
>( m_aSymbolSize
.Width() + m_aSymbolSize
.Height() )/2 );
1586 aSize
.setHeight( static_cast<tools::Long
>( m_aSymbolSize
.Width() + m_aSymbolSize
.Height() )/2 );
1587 m_aSymbolSize
= aSize
;
1590 m_aCtlPreview
.SetSymbol(&m_aSymbolGraphic
,m_aSymbolSize
);
1594 m_aSymbolGraphic
=Graphic();
1595 m_aCtlPreview
.SetSymbol(nullptr,m_aSymbolSize
);
1598 m_aSymbolLastSize
=m_aSymbolSize
;
1599 SetMetricValue(*m_xSymbolWidthMF
, m_aSymbolSize
.Width(), m_ePoolUnit
);
1600 SetMetricValue(*m_xSymbolHeightMF
, m_aSymbolSize
.Height(), m_ePoolUnit
);
1602 m_xGridIconSize
->set_sensitive(bEnable
);
1603 m_aCtlPreview
.Invalidate();
1606 IMPL_LINK( SvxLineTabPage
, SizeHdl_Impl
, weld::MetricSpinButton
&, rField
, void)
1609 bool bWidth
= &rField
== m_xSymbolWidthMF
.get();
1610 m_bLastWidthModified
= bWidth
;
1611 bool bRatio
= m_xSymbolRatioCB
->get_active();
1612 tools::Long nWidthVal
= static_cast<tools::Long
>(m_xSymbolWidthMF
->denormalize(m_xSymbolWidthMF
->get_value(FieldUnit::MM_100TH
)));
1613 tools::Long nHeightVal
= static_cast<tools::Long
>(m_xSymbolHeightMF
->denormalize(m_xSymbolHeightMF
->get_value(FieldUnit::MM_100TH
)));
1614 nWidthVal
= OutputDevice::LogicToLogic(nWidthVal
,MapUnit::Map100thMM
, m_ePoolUnit
);
1615 nHeightVal
= OutputDevice::LogicToLogic(nHeightVal
,MapUnit::Map100thMM
, m_ePoolUnit
);
1616 m_aSymbolSize
= Size(nWidthVal
,nHeightVal
);
1617 double fSizeRatio
= double(1);
1621 if (m_aSymbolLastSize
.Height() && m_aSymbolLastSize
.Width())
1622 fSizeRatio
= static_cast<double>(m_aSymbolLastSize
.Width()) / m_aSymbolLastSize
.Height();
1627 tools::Long nDelta
= nWidthVal
- m_aSymbolLastSize
.Width();
1628 m_aSymbolSize
.setWidth( nWidthVal
);
1631 m_aSymbolSize
.setHeight( m_aSymbolLastSize
.Height() + static_cast<tools::Long
>(static_cast<double>(nDelta
) / fSizeRatio
) );
1632 m_aSymbolSize
.setHeight( OutputDevice::LogicToLogic( m_aSymbolSize
.Height(), m_ePoolUnit
, MapUnit::Map100thMM
) );
1633 //TODO m_xSymbolHeightMF->SetUserValue(m_xSymbolHeightMF->normalize(m_aSymbolSize.Height()), FieldUnit::MM_100TH);
1634 m_xSymbolHeightMF
->set_value(m_xSymbolHeightMF
->normalize(m_aSymbolSize
.Height()), FieldUnit::MM_100TH
);
1639 tools::Long nDelta
= nHeightVal
- m_aSymbolLastSize
.Height();
1640 m_aSymbolSize
.setHeight( nHeightVal
);
1643 m_aSymbolSize
.setWidth( m_aSymbolLastSize
.Width() + static_cast<tools::Long
>(static_cast<double>(nDelta
) * fSizeRatio
) );
1644 m_aSymbolSize
.setWidth( OutputDevice::LogicToLogic( m_aSymbolSize
.Width(), m_ePoolUnit
, MapUnit::Map100thMM
) );
1645 //TODO m_xSymbolWidthMF->SetUserValue(m_xSymbolWidthMF->normalize(m_aSymbolSize.Width()), FieldUnit::MM_100TH);
1646 m_xSymbolWidthMF
->set_value(m_xSymbolWidthMF
->normalize(m_aSymbolSize
.Width()), FieldUnit::MM_100TH
);
1649 m_aCtlPreview
.ResizeSymbol(m_aSymbolSize
);
1650 m_aSymbolLastSize
=m_aSymbolSize
;
1653 IMPL_LINK(SvxLineTabPage
, RatioHdl_Impl
, weld::Toggleable
&, rBox
, void)
1655 if (rBox
.get_active())
1657 if (m_bLastWidthModified
)
1658 SizeHdl_Impl(*m_xSymbolWidthMF
);
1660 SizeHdl_Impl(*m_xSymbolHeightMF
);
1664 void SvxLineTabPage::PageCreated(const SfxAllItemSet
& aSet
)
1666 const SvxDashListItem
* pDashListItem
= aSet
.GetItem
<SvxDashListItem
>(SID_DASH_LIST
, false);
1667 const SvxLineEndListItem
* pLineEndListItem
= aSet
.GetItem
<SvxLineEndListItem
>(SID_LINEEND_LIST
, false);
1668 const SfxUInt16Item
* pPageTypeItem
= aSet
.GetItem
<SfxUInt16Item
>(SID_PAGE_TYPE
, false);
1669 const SfxUInt16Item
* pDlgTypeItem
= aSet
.GetItem
<SfxUInt16Item
>(SID_DLG_TYPE
, false);
1670 const OfaPtrItem
* pSdrObjListItem
= aSet
.GetItem
<OfaPtrItem
>(SID_OBJECT_LIST
, false);
1671 const SfxTabDialogItem
* pSymbolAttrItem
= aSet
.GetItem
<SfxTabDialogItem
>(SID_ATTR_SET
, false);
1672 const SvxGraphicItem
* pGraphicItem
= aSet
.GetItem
<SvxGraphicItem
>(SID_GRAPHIC
, false);
1675 SetDashList(pDashListItem
->GetDashList());
1676 if (pLineEndListItem
)
1677 SetLineEndList(pLineEndListItem
->GetLineEndList());
1679 SetPageType(static_cast<PageType
>(pPageTypeItem
->GetValue()));
1681 SetDlgType(pDlgTypeItem
->GetValue());
1684 if(pSdrObjListItem
) //symbols
1686 ShowSymbolControls(true);
1687 m_pSymbolList
= static_cast<SdrObjList
*>(pSdrObjListItem
->GetValue());
1688 if (pSymbolAttrItem
)
1689 m_xSymbolAttr
.reset(new SfxItemSet(pSymbolAttrItem
->GetItemSet()));
1691 m_aAutoSymbolGraphic
= pGraphicItem
->GetGraphic();
1695 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */