diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-07-28 18:52:30 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-07-30 05:45:21 +0200 |
commit | fee180f13d48c1fa97a3ecde4b2067e5b0f13fc2 (patch) | |
tree | f8af7bd44844becb79a3a0ba2ddd20a80c5da884 /svx/source/sidebar | |
parent | ddca8df5308d57142815c1b9975e4ab8d646524f (diff) |
split the line width panel into two pieces
The new LinePropertyPanelBase has no reference to SfxBindings anymore.
Change-Id: I7d1d1bb351066dca8bfeedc559048f8337e47f67
Diffstat (limited to 'svx/source/sidebar')
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanel.cxx | 840 | ||||
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanel.hxx | 79 | ||||
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanelBase.cxx | 930 | ||||
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanelBase.hxx | 172 | ||||
-rw-r--r-- | svx/source/sidebar/line/LineWidthControl.cxx | 12 | ||||
-rw-r--r-- | svx/source/sidebar/line/LineWidthControl.hxx | 7 |
6 files changed, 1164 insertions, 876 deletions
diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx index 59c56dad759c..c025c86f00d4 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.cxx +++ b/svx/source/sidebar/line/LinePropertyPanel.cxx @@ -55,102 +55,13 @@ using namespace css; using namespace css::uno; using sfx2::sidebar::Theme; -const char UNO_SELECTWIDTH[] = ".uno:SelectWidth"; - -namespace -{ - -void FillLineEndListBox(ListBox& rListBoxStart, ListBox& rListBoxEnd, const XLineEndList& rList) -{ - const sal_uInt32 nCount(rList.Count()); - const OUString sNone(SVX_RESSTR(RID_SVXSTR_NONE)); - - rListBoxStart.SetUpdateMode(false); - rListBoxEnd.SetUpdateMode(false); - - rListBoxStart.Clear(); - rListBoxEnd.Clear(); - - // add 'none' entries - rListBoxStart.InsertEntry(sNone); - rListBoxEnd.InsertEntry(sNone); - - for(sal_uInt32 i(0); i < nCount; i++) - { - XLineEndEntry* pEntry = rList.GetLineEnd(i); - const Bitmap aBitmap = const_cast< XLineEndList& >(rList).GetUiBitmap(i); - - if(!aBitmap.IsEmpty()) - { - Bitmap aCopyStart(aBitmap); - Bitmap aCopyEnd(aBitmap); - - const Size aBmpSize(aCopyStart.GetSizePixel()); - const Rectangle aCropRectStart(Point(), Size(aBmpSize.Width() / 2, aBmpSize.Height())); - const Rectangle aCropRectEnd(Point(aBmpSize.Width() / 2, 0), Size(aBmpSize.Width() / 2, aBmpSize.Height())); - - aCopyStart.Crop(aCropRectStart); - rListBoxStart.InsertEntry( - pEntry->GetName(), - Image(aCopyStart)); - - aCopyEnd.Crop(aCropRectEnd); - rListBoxEnd.InsertEntry( - pEntry->GetName(), - Image(aCopyEnd)); - } - else - { - rListBoxStart.InsertEntry(pEntry->GetName()); - rListBoxEnd.InsertEntry(pEntry->GetName()); - } - } - - rListBoxStart.SetUpdateMode(true); - rListBoxEnd.SetUpdateMode(true); -} - -void FillLineStyleListBox(ListBox& rListBox, const XDashList& rList) -{ - const sal_uInt32 nCount(rList.Count()); - rListBox.SetUpdateMode(false); - - rListBox.Clear(); - - // entry for 'none' - rListBox.InsertEntry(rList.GetStringForUiNoLine()); - - // entry for solid line - rListBox.InsertEntry(rList.GetStringForUiSolidLine(), - Image( rList.GetBitmapForUISolidLine())); - - for(sal_uInt32 i(0); i < nCount; i++) - { - XDashEntry* pEntry = rList.GetDash(i); - const Bitmap aBitmap = const_cast< XDashList& >(rList).GetUiBitmap(i); - - if(!aBitmap.IsEmpty()) - { - rListBox.InsertEntry(pEntry->GetName(), Image(aBitmap)); - } - else - { - rListBox.InsertEntry(pEntry->GetName()); - } - } - - rListBox.SetUpdateMode(true); -} - -} // end of anonymous namespace - namespace svx { namespace sidebar { LinePropertyPanel::LinePropertyPanel( vcl::Window* pParent, const uno::Reference<frame::XFrame>& rxFrame, SfxBindings* pBindings) -: PanelLayout(pParent, "LinePropertyPanel", "svx/ui/sidebarline.ui", rxFrame), +: LinePropertyPanelBase(pParent, rxFrame), maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this), maDashControl (SID_ATTR_LINE_DASH, *pBindings, *this), maWidthControl(SID_ATTR_LINE_WIDTH, *pBindings, *this), @@ -161,36 +72,8 @@ LinePropertyPanel::LinePropertyPanel( maTransControl(SID_ATTR_LINE_TRANSPARENCE, *pBindings, *this), maEdgeStyle(SID_ATTR_LINE_JOINT, *pBindings, *this), maCapStyle(SID_ATTR_LINE_CAP, *pBindings, *this), - mpStyleItem(), - mpDashItem(), - mnTrans(0), - meMapUnit(SFX_MAPUNIT_MM), - mnWidthCoreValue(0), - mpStartItem(), - mpEndItem(), - maLineWidthPopup(this, ::boost::bind(&LinePropertyPanel::CreateLineWidthPopupControl, this, _1)), - maIMGNone(SVX_RES(IMG_NONE_ICON)), - mpIMGWidthIcon(), - mxFrame(rxFrame), - mpBindings(pBindings), - mbWidthValuable(true) + mpBindings(pBindings) { - get(mpFTWidth, "widthlabel"); - get(mpTBWidth, "width"); - get(mpFTStyle, "stylelabel"); - get(mpLBStyle, "linestyle"); - get(mpFTTransparency, "translabel"); - get(mpMFTransparent, "linetransparency"); - get(mpFTArrow, "arrowlabel"); - get(mpLBStart, "beginarrowstyle"); - get(mpLBEnd, "endarrowstyle"); - get(mpFTEdgeStyle, "cornerlabel"); - get(mpLBEdgeStyle, "edgestyle"); - get(mpFTCapStyle, "caplabel"); - get(mpLBCapStyle, "linecapstyle"); - get(mpGridLineProps, "lineproperties"); - get(mpBoxArrowProps, "arrowproperties"); - Initialize(); } @@ -201,24 +84,6 @@ LinePropertyPanel::~LinePropertyPanel() void LinePropertyPanel::dispose() { - mpFTWidth.clear(); - mpTBWidth.clear(); - mpFTStyle.clear(); - mpLBStyle.clear(); - mpFTTransparency.clear(); - mpMFTransparent.clear(); - mpFTArrow.clear(); - mpLBStart.clear(); - mpLBEnd.clear(); - mpFTEdgeStyle.clear(); - mpLBEdgeStyle.clear(); - mpFTCapStyle.clear(); - mpLBCapStyle.clear(); - mpGridLineProps.clear(); - mpBoxArrowProps.clear(); - - - maLineWidthPopup.dispose(); maStyleControl.dispose(); maDashControl.dispose(); maWidthControl.dispose(); @@ -230,68 +95,11 @@ void LinePropertyPanel::dispose() maEdgeStyle.dispose(); maCapStyle.dispose(); - PanelLayout::dispose(); + LinePropertyPanelBase::dispose(); } void LinePropertyPanel::Initialize() { - mpIMGWidthIcon.reset(new Image[8]); - mpIMGWidthIcon[0] = Image(SVX_RES(IMG_WIDTH1_ICON)); - mpIMGWidthIcon[1] = Image(SVX_RES(IMG_WIDTH2_ICON)); - mpIMGWidthIcon[2] = Image(SVX_RES(IMG_WIDTH3_ICON)); - mpIMGWidthIcon[3] = Image(SVX_RES(IMG_WIDTH4_ICON)); - mpIMGWidthIcon[4] = Image(SVX_RES(IMG_WIDTH5_ICON)); - mpIMGWidthIcon[5] = Image(SVX_RES(IMG_WIDTH6_ICON)); - mpIMGWidthIcon[6] = Image(SVX_RES(IMG_WIDTH7_ICON)); - mpIMGWidthIcon[7] = Image(SVX_RES(IMG_WIDTH8_ICON)); - - meMapUnit = maWidthControl.GetCoreMetric(); - - FillLineStyleList(); - SelectLineStyle(); - Link<> aLink = LINK( this, LinePropertyPanel, ChangeLineStyleHdl ); - mpLBStyle->SetSelectHdl( aLink ); - mpLBStyle->SetAccessibleName(OUString( "Style")); - mpLBStyle->AdaptDropDownLineCountToMaximum(); - - const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); - mpTBWidth->SetItemImage(nIdWidth, mpIMGWidthIcon[0]); - mpTBWidth->SetItemBits( nIdWidth, mpTBWidth->GetItemBits( nIdWidth ) | ToolBoxItemBits::DROPDOWNONLY ); - Link<ToolBox *, void> aLink2 = LINK(this, LinePropertyPanel, ToolboxWidthSelectHdl); - mpTBWidth->SetDropdownClickHdl ( aLink2 ); - mpTBWidth->SetSelectHdl ( aLink2 ); - - FillLineEndList(); - SelectEndStyle(true); - SelectEndStyle(false); - aLink = LINK( this, LinePropertyPanel, ChangeStartHdl ); - mpLBStart->SetSelectHdl( aLink ); - mpLBStart->SetAccessibleName(OUString("Beginning Style")); //wj acc - mpLBStart->AdaptDropDownLineCountToMaximum(); - aLink = LINK( this, LinePropertyPanel, ChangeEndHdl ); - mpLBEnd->SetSelectHdl( aLink ); - mpLBEnd->SetAccessibleName(OUString("Ending Style")); //wj acc - mpLBEnd->AdaptDropDownLineCountToMaximum(); - - aLink = LINK(this, LinePropertyPanel, ChangeTransparentHdl); - mpMFTransparent->SetModifyHdl(aLink); - mpMFTransparent->SetAccessibleName(OUString("Transparency")); //wj acc - - mpTBWidth->SetAccessibleRelationLabeledBy(mpFTWidth); - mpLBStyle->SetAccessibleRelationLabeledBy(mpFTStyle); - mpMFTransparent->SetAccessibleRelationLabeledBy(mpFTTransparency); - mpLBStart->SetAccessibleRelationLabeledBy(mpFTArrow); - mpLBEnd->SetAccessibleRelationLabeledBy(mpLBEnd); - - aLink = LINK( this, LinePropertyPanel, ChangeEdgeStyleHdl ); - mpLBEdgeStyle->SetSelectHdl( aLink ); - mpLBEdgeStyle->SetAccessibleName(OUString("Corner Style")); - - aLink = LINK( this, LinePropertyPanel, ChangeCapStyleHdl ); - mpLBCapStyle->SetSelectHdl( aLink ); - mpLBCapStyle->SetAccessibleName(OUString("Cap Style")); - - ActivateControls(); } VclPtr<vcl::Window> LinePropertyPanel::Create ( @@ -309,10 +117,6 @@ VclPtr<vcl::Window> LinePropertyPanel::Create ( return VclPtr<LinePropertyPanel>::Create(pParent, rxFrame, pBindings); } -void LinePropertyPanel::DataChanged(const DataChangedEvent& /*rEvent*/) -{ -} - void LinePropertyPanel::NotifyItemUpdate( sal_uInt16 nSID, SfxItemState eState, @@ -320,174 +124,44 @@ void LinePropertyPanel::NotifyItemUpdate( const bool /*bIsEnabled*/) { const bool bDisabled(SfxItemState::DISABLED == eState); + const bool bSetOrDefault = eState >= SfxItemState::DEFAULT; switch(nSID) { case SID_ATTR_LINE_DASH: + { + const XLineDashItem* pItem = dynamic_cast<const XLineDashItem*>(pState); + updateLineDash(bDisabled, bSetOrDefault, pItem); + } + break; case SID_ATTR_LINE_STYLE: { - if(bDisabled) - { - mpFTStyle->Disable(); - mpLBStyle->Disable(); - } - else - { - mpFTStyle->Enable(); - mpLBStyle->Enable(); - } - - if(eState >= SfxItemState::DEFAULT) - { - if(nSID == SID_ATTR_LINE_STYLE) - { - const XLineStyleItem* pItem = dynamic_cast< const XLineStyleItem* >(pState); - - if(pItem) - { - mpStyleItem.reset(pState ? static_cast<XLineStyleItem*>(pItem->Clone()) : 0); - } - } - else // if(nSID == SID_ATTR_LINE_DASH) - { - const XLineDashItem* pItem = dynamic_cast< const XLineDashItem* >(pState); - - if(pItem) - { - mpDashItem.reset(pState ? static_cast<XLineDashItem*>(pItem->Clone()) : 0); - } - } - } - else - { - if(nSID == SID_ATTR_LINE_STYLE) - { - mpStyleItem.reset(0); - } - else - { - mpDashItem.reset(0); - } - } - - SelectLineStyle(); - break; + const XLineStyleItem* pItem = dynamic_cast<const XLineStyleItem*>(pState); + updateLineStyle(bDisabled, bSetOrDefault, pItem); } + break; case SID_ATTR_LINE_TRANSPARENCE: { - if(bDisabled) - { - mpFTTransparency->Disable(); - mpMFTransparent->Disable(); - } - else - { - mpFTTransparency->Enable(); - mpMFTransparent->Enable(); - } - - if(eState >= SfxItemState::DEFAULT) - { - const XLineTransparenceItem* pItem = dynamic_cast< const XLineTransparenceItem* >(pState); - - if(pItem) - { - mnTrans = pItem->GetValue(); - mpMFTransparent->SetValue(mnTrans); - break; - } - } - - mpMFTransparent->SetValue(0);//add - mpMFTransparent->SetText(OUString()); + const XLineTransparenceItem* pItem = dynamic_cast<const XLineTransparenceItem*>(pState); + updateLineTransparence(bDisabled, bSetOrDefault, pItem); break; } case SID_ATTR_LINE_WIDTH: { - if(bDisabled) - { - mpTBWidth->Disable(); - mpFTWidth->Disable(); - } - else - { - mpTBWidth->Enable(); - mpFTWidth->Enable(); - } - - if(eState >= SfxItemState::DEFAULT) - { - const XLineWidthItem* pItem = dynamic_cast< const XLineWidthItem* >(pState); - - if(pItem) - { - mnWidthCoreValue = pItem->GetValue(); - mbWidthValuable = true; - SetWidthIcon(); - break; - } - } - - mbWidthValuable = false; - SetWidthIcon(); + const XLineWidthItem* pItem = dynamic_cast<const XLineWidthItem*>(pState); + updateLineWidth(bDisabled, bSetOrDefault, pItem); break; } case SID_ATTR_LINE_START: { - if(bDisabled) - { - mpFTArrow->Disable(); - mpLBStart->Disable(); - } - else - { - mpFTArrow->Enable(); - mpLBStart->Enable(); - } - - if(eState >= SfxItemState::DEFAULT) - { - const XLineStartItem* pItem = dynamic_cast< const XLineStartItem* >(pState); - - if(pItem) - { - mpStartItem.reset(static_cast<XLineStartItem*>(pItem->Clone())); - SelectEndStyle(true); - break; - } - } - - mpStartItem.reset(0); - SelectEndStyle(true); + const XLineStartItem* pItem = dynamic_cast<const XLineStartItem*>(pState); + updateLineStart(bDisabled, bSetOrDefault, pItem); break; } case SID_ATTR_LINE_END: { - if(bDisabled) - { - mpFTArrow->Disable(); - mpLBEnd->Disable(); - } - else - { - mpFTArrow->Enable(); - mpLBEnd->Enable(); - } - - if(eState >= SfxItemState::DEFAULT) - { - const XLineEndItem* pItem = dynamic_cast< const XLineEndItem* >(pState); - - if(pItem) - { - mpEndItem.reset(static_cast<XLineEndItem*>(pItem->Clone())); - SelectEndStyle(false); - break; - } - } - - mpEndItem.reset(0); - SelectEndStyle(false); + const XLineEndItem* pItem = dynamic_cast<const XLineEndItem*>(pState); + updateLineEnd(bDisabled, bSetOrDefault, pItem); break; } case SID_LINEEND_LIST: @@ -505,492 +179,58 @@ void LinePropertyPanel::NotifyItemUpdate( } case SID_ATTR_LINE_JOINT: { - if(bDisabled) - { - mpLBEdgeStyle->Disable(); - mpFTEdgeStyle->Disable(); - } - else - { - mpLBEdgeStyle->Enable(); - mpFTEdgeStyle->Enable(); - } - - if(eState >= SfxItemState::DEFAULT) - { - const XLineJointItem* pItem = dynamic_cast< const XLineJointItem* >(pState); - - if(pItem) - { - sal_Int32 nEntryPos(0); - - switch(pItem->GetValue()) - { - case drawing::LineJoint_MIDDLE: - case drawing::LineJoint_ROUND: - { - nEntryPos = 1; - break; - } - case drawing::LineJoint_NONE: - { - nEntryPos = 2; - break; - } - case drawing::LineJoint_MITER: - { - nEntryPos = 3; - break; - } - case drawing::LineJoint_BEVEL: - { - nEntryPos = 4; - break; - } - - default: - break; - } - - if(nEntryPos) - { - mpLBEdgeStyle->SelectEntryPos(nEntryPos - 1); - break; - } - } - } - - mpLBEdgeStyle->SetNoSelection(); + const XLineJointItem* pItem = dynamic_cast<const XLineJointItem*>(pState); + updateLineJoint(bDisabled, bSetOrDefault, pItem); break; } case SID_ATTR_LINE_CAP: { - if(bDisabled) - { - mpLBCapStyle->Disable(); - mpFTCapStyle->Disable(); - } - else - { - mpLBCapStyle->Enable(); - mpLBCapStyle->Enable(); - } - - if(eState >= SfxItemState::DEFAULT) - { - const XLineCapItem* pItem = dynamic_cast< const XLineCapItem* >(pState); - - if(pItem) - { - sal_Int32 nEntryPos(0); - - switch(pItem->GetValue()) - { - case drawing::LineCap_BUTT: - { - nEntryPos = 1; - break; - } - case drawing::LineCap_ROUND: - { - nEntryPos = 2; - break; - } - case drawing::LineCap_SQUARE: - { - nEntryPos = 3; - break; - } - - default: - break; - } - - if(nEntryPos) - { - mpLBCapStyle->SelectEntryPos(nEntryPos - 1); - break; - } - } - } - - mpLBCapStyle->SetNoSelection(); + const XLineCapItem* pItem = dynamic_cast<const XLineCapItem*>(pState); + updateLineCap(bDisabled, bSetOrDefault, pItem); break; } } ActivateControls(); } -IMPL_LINK_NOARG(LinePropertyPanel, ChangeLineStyleHdl) +void LinePropertyPanel::setLineStyle(const XLineStyleItem& rItem) { - const sal_Int32 nPos(mpLBStyle->GetSelectEntryPos()); - - if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBStyle->IsValueChangedFromSaved()) - { - if(0 == nPos) - { - // drawing::LineStyle_NONE - const XLineStyleItem aItem(drawing::LineStyle_NONE); - - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SfxCallMode::RECORD, &aItem, 0L); - } - else if(1 == nPos) - { - // drawing::LineStyle_SOLID - const XLineStyleItem aItem(drawing::LineStyle_SOLID); - - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SfxCallMode::RECORD, &aItem, 0L); - } - else if (mxLineStyleList.is() && mxLineStyleList->Count() > (long)(nPos - 2)) - { - // drawing::LineStyle_DASH - const XLineStyleItem aItemA(drawing::LineStyle_DASH); - const XDashEntry* pDashEntry = mxLineStyleList->GetDash(nPos - 2); - OSL_ENSURE(pDashEntry, "OOps, got empty XDash from XDashList (!)"); - const XLineDashItem aItemB( - pDashEntry ? pDashEntry->GetName() : OUString(), - pDashEntry ? pDashEntry->GetDash() : XDash()); - - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SfxCallMode::RECORD, &aItemA, 0L); - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_DASH, SfxCallMode::RECORD, &aItemB, 0L); - } - } - ActivateControls(); - return 0; + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SfxCallMode::RECORD, &rItem, 0L); } -IMPL_LINK_NOARG(LinePropertyPanel, ChangeStartHdl) +void LinePropertyPanel::setLineDash(const XLineDashItem& rItem) { - sal_Int32 nPos = mpLBStart->GetSelectEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBStart->IsValueChangedFromSaved() ) - { - std::unique_ptr<XLineStartItem> pItem; - if( nPos == 0 ) - pItem.reset(new XLineStartItem()); - else if( mxLineEndList.is() && mxLineEndList->Count() > (long) ( nPos - 1 ) ) - pItem.reset(new XLineStartItem( mpLBStart->GetSelectEntry(),mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() )); - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SfxCallMode::RECORD, pItem.get(), 0L); - } - return 0; -} - -IMPL_LINK_NOARG(LinePropertyPanel, ChangeEndHdl) -{ - sal_Int32 nPos = mpLBEnd->GetSelectEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBEnd->IsValueChangedFromSaved() ) - { - std::unique_ptr<XLineEndItem> pItem; - if( nPos == 0 ) - pItem.reset(new XLineEndItem()); - else if( mxLineEndList.is() && mxLineEndList->Count() > (long) ( nPos - 1 ) ) - pItem.reset(new XLineEndItem( mpLBEnd->GetSelectEntry(), mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() )); - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SfxCallMode::RECORD, pItem.get(), 0L); - } - return 0; -} - -IMPL_LINK_NOARG(LinePropertyPanel, ChangeEdgeStyleHdl) -{ - const sal_Int32 nPos(mpLBEdgeStyle->GetSelectEntryPos()); - - if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBEdgeStyle->IsValueChangedFromSaved()) - { - std::unique_ptr<XLineJointItem> pItem; - - switch(nPos) - { - case 0: // rounded - { - pItem.reset(new XLineJointItem(drawing::LineJoint_ROUND)); - break; - } - case 1: // none - { - pItem.reset(new XLineJointItem(drawing::LineJoint_NONE)); - break; - } - case 2: // mitered - { - pItem.reset(new XLineJointItem(drawing::LineJoint_MITER)); - break; - } - case 3: // beveled - { - pItem.reset(new XLineJointItem(drawing::LineJoint_BEVEL)); - break; - } - } - - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_JOINT, SfxCallMode::RECORD, pItem.get(), 0L); - } - return 0; -} - -IMPL_LINK_NOARG(LinePropertyPanel, ChangeCapStyleHdl) -{ - const sal_Int32 nPos(mpLBCapStyle->GetSelectEntryPos()); - - if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBCapStyle->IsValueChangedFromSaved()) - { - std::unique_ptr<XLineCapItem> pItem; - - switch(nPos) - { - case 0: // flat - { - pItem.reset(new XLineCapItem(drawing::LineCap_BUTT)); - break; - } - case 1: // round - { - pItem.reset(new XLineCapItem(drawing::LineCap_ROUND)); - break; - } - case 2: // square - { - pItem.reset(new XLineCapItem(drawing::LineCap_SQUARE)); - break; - } - } - - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_CAP, SfxCallMode::RECORD, pItem.get(), 0L); - } - return 0; -} - -IMPL_LINK_TYPED(LinePropertyPanel, ToolboxWidthSelectHdl,ToolBox*, pToolBox, void) -{ - if (pToolBox->GetItemCommand(pToolBox->GetCurItemId()) == UNO_SELECTWIDTH) - { - maLineWidthPopup.SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit); - maLineWidthPopup.Show(*pToolBox); - } -} - -IMPL_LINK_NOARG( LinePropertyPanel, ChangeTransparentHdl ) -{ - sal_uInt16 nVal = (sal_uInt16)mpMFTransparent->GetValue(); - XLineTransparenceItem aItem( nVal ); - - GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SfxCallMode::RECORD, &aItem, 0L); - return 0L; -} - -VclPtr<PopupControl> LinePropertyPanel::CreateLineWidthPopupControl (PopupContainer* pParent) -{ - return VclPtrInstance<LineWidthControl>(pParent, *this); + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_DASH, SfxCallMode::RECORD, &rItem, 0L); } -void LinePropertyPanel::ActivateControls() +void LinePropertyPanel::setLineEndStyle(const XLineEndItem* pItem) { - const sal_Int32 nPos(mpLBStyle->GetSelectEntryPos()); - bool bLineStyle( nPos != 0 ); - - mpGridLineProps->Enable( bLineStyle ); - mpBoxArrowProps->Enable( bLineStyle ); -} - -void LinePropertyPanel::EndLineWidthPopupMode() -{ - maLineWidthPopup.Hide(); -} - -void LinePropertyPanel::SetWidthIcon(int n) -{ - const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); - if (n == 0) - mpTBWidth->SetItemImage( nIdWidth, maIMGNone); - else - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[n-1]); -} - -void LinePropertyPanel::SetWidthIcon() -{ - if(!mbWidthValuable) - { - const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); - mpTBWidth->SetItemImage(nIdWidth, maIMGNone); - return; - } - - long nVal = LogicToLogic(mnWidthCoreValue * 10,(MapUnit)meMapUnit , MAP_POINT); - const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); - - if(nVal <= 6) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[0]); - else if(nVal > 6 && nVal <= 9) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[1]); - else if(nVal > 9 && nVal <= 12) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[2]); - else if(nVal > 12 && nVal <= 19) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[3]); - else if(nVal > 19 && nVal <= 26) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[4]); - else if(nVal > 26 && nVal <= 37) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[5]); - else if(nVal > 37 && nVal <=52) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[6]); - else if(nVal > 52) - mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[7]); - + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SfxCallMode::RECORD, pItem, 0L); } -void LinePropertyPanel::SetWidth(long nWidth) +void LinePropertyPanel::setLineStartStyle(const XLineStartItem* pItem) { - mnWidthCoreValue = nWidth; - mbWidthValuable = true; + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SfxCallMode::RECORD, pItem, 0L); } -void LinePropertyPanel::FillLineEndList() +void LinePropertyPanel::setLineJoint(const XLineJointItem* pItem) { - SfxObjectShell* pSh = SfxObjectShell::Current(); - if ( pSh && pSh->GetItem( SID_LINEEND_LIST ) ) - { - mpLBStart->Enable(); - SvxLineEndListItem aItem( *static_cast<const SvxLineEndListItem*>(pSh->GetItem( SID_LINEEND_LIST ) ) ); - mxLineEndList = aItem.GetLineEndList(); - - if (mxLineEndList.is()) - { - FillLineEndListBox(*mpLBStart, *mpLBEnd, *mxLineEndList); - } - - mpLBStart->SelectEntryPos(0); - mpLBEnd->SelectEntryPos(0); - } - else - { - mpLBStart->Disable(); - mpLBEnd->Disable(); - } + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_JOINT, SfxCallMode::RECORD, pItem, 0L); } -void LinePropertyPanel::FillLineStyleList() +void LinePropertyPanel::setLineCap(const XLineCapItem* pItem) { - SfxObjectShell* pSh = SfxObjectShell::Current(); - if ( pSh && pSh->GetItem( SID_DASH_LIST ) ) - { - mpLBStyle->Enable(); - SvxDashListItem aItem( *static_cast<const SvxDashListItem*>(pSh->GetItem( SID_DASH_LIST ) ) ); - mxLineStyleList = aItem.GetDashList(); - - if (mxLineStyleList.is()) - { - FillLineStyleListBox(*mpLBStyle, *mxLineStyleList); - } - - mpLBStyle->SelectEntryPos(0); - } - else - { - mpLBStyle->Disable(); - } + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_CAP, SfxCallMode::RECORD, pItem, 0L); } -void LinePropertyPanel::SelectLineStyle() +void LinePropertyPanel::setLineTransparency(const XLineTransparenceItem& rItem) { - if( !mpStyleItem.get() || !mpDashItem.get() ) - { - mpLBStyle->SetNoSelection(); - mpLBStyle->Disable(); - return; - } - - const drawing::LineStyle eXLS(mpStyleItem ? (drawing::LineStyle)mpStyleItem->GetValue() : drawing::LineStyle_NONE); - bool bSelected(false); - - switch(eXLS) - { - case drawing::LineStyle_NONE: - break; - case drawing::LineStyle_SOLID: - mpLBStyle->SelectEntryPos(1); - bSelected = true; - break; - default: - if(mpDashItem && mxLineStyleList.is()) - { - const XDash& rDash = mpDashItem->GetDashValue(); - for(sal_Int32 a(0);!bSelected && a < mxLineStyleList->Count(); a++) - { - XDashEntry* pEntry = mxLineStyleList->GetDash(a); - const XDash& rEntry = pEntry->GetDash(); - if(rDash == rEntry) - { - mpLBStyle->SelectEntryPos(a + 2); - bSelected = true; - } - } - } - break; - } - - if(!bSelected) - mpLBStyle->SelectEntryPos( 0 ); + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SfxCallMode::RECORD, &rItem, 0L); } -void LinePropertyPanel::SelectEndStyle(bool bStart) +void LinePropertyPanel::setLineWidth(const XLineWidthItem& rItem) { - bool bSelected(false); - - if(bStart) - { - if( !mpStartItem.get() ) - { - mpLBStart->SetNoSelection(); - mpLBStart->Disable(); - return; - } - - if (mpStartItem && mxLineEndList.is()) - { - const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue(); - for(sal_Int32 a(0);!bSelected && a < mxLineEndList->Count(); a++) - { - XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a); - const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); - if(rItemPolygon == rEntryPolygon) - { - mpLBStart->SelectEntryPos(a + 1); - bSelected = true; - } - } - } - - if(!bSelected) - { - mpLBStart->SelectEntryPos( 0 ); - } - } - else - { - if( !mpEndItem.get() ) - { - mpLBEnd->SetNoSelection(); - mpLBEnd->Disable(); - return; - } - - if (mpEndItem && mxLineEndList.is()) - { - const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue(); - for(sal_Int32 a(0);!bSelected && a < mxLineEndList->Count(); a++) - { - XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a); - const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); - if(rItemPolygon == rEntryPolygon) - { - mpLBEnd->SelectEntryPos(a + 1); - bSelected = true; - } - } - } - - if(!bSelected) - { - mpLBEnd->SelectEntryPos( 0 ); - } - } + GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_WIDTH, SfxCallMode::RECORD, &rItem, 0L); } }} // end of namespace svx::sidebar diff --git a/svx/source/sidebar/line/LinePropertyPanel.hxx b/svx/source/sidebar/line/LinePropertyPanel.hxx index cfbcd4a961b4..6a94423cd4cd 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.hxx +++ b/svx/source/sidebar/line/LinePropertyPanel.hxx @@ -30,6 +30,7 @@ #include <svx/sidebar/PanelLayout.hxx> #include <svx/xtable.hxx> #include "LineWidthPopup.hxx" +#include "LinePropertyPanelBase.hxx" class XLineStyleItem; @@ -57,7 +58,7 @@ namespace sidebar class PopupContainer; class LineWidthControl; -class LinePropertyPanel : public PanelLayout, +class LinePropertyPanel : public LinePropertyPanelBase, public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { public: @@ -69,9 +70,6 @@ public: const css::uno::Reference<css::frame::XFrame>& rxFrame, SfxBindings* pBindings); - virtual void DataChanged( - const DataChangedEvent& rEvent) SAL_OVERRIDE; - virtual void NotifyItemUpdate( const sal_uInt16 nSId, const SfxItemState eState, @@ -80,36 +78,25 @@ public: SfxBindings* GetBindings() { return mpBindings;} - void SetWidth(long nWidth); - void SetWidthIcon(int n); - void SetWidthIcon(); - - void EndLineWidthPopupMode(); - // constructor/destuctor LinePropertyPanel( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, SfxBindings* pBindings); -private: - //ui controls - VclPtr<FixedText> mpFTWidth; - VclPtr<ToolBox> mpTBWidth; - VclPtr<FixedText> mpFTStyle; - VclPtr<ListBox> mpLBStyle; - VclPtr<FixedText> mpFTTransparency; - VclPtr<MetricField> mpMFTransparent; - VclPtr<FixedText> mpFTArrow; - VclPtr<ListBox> mpLBStart; - VclPtr<ListBox> mpLBEnd; - VclPtr<FixedText> mpFTEdgeStyle; - VclPtr<ListBox> mpLBEdgeStyle; - VclPtr<FixedText> mpFTCapStyle; - VclPtr<ListBox> mpLBCapStyle; - VclPtr<VclGrid> mpGridLineProps; - VclPtr<VclVBox> mpBoxArrowProps; + virtual void setLineWidth(const XLineWidthItem& rItem) SAL_OVERRIDE; +protected: + + virtual void setLineStyle(const XLineStyleItem& rItem) SAL_OVERRIDE; + virtual void setLineDash(const XLineDashItem& rItem) SAL_OVERRIDE; + virtual void setLineEndStyle(const XLineEndItem* pItem) SAL_OVERRIDE; + virtual void setLineStartStyle(const XLineStartItem* pItem) SAL_OVERRIDE; + virtual void setLineTransparency(const XLineTransparenceItem& rItem) SAL_OVERRIDE; + virtual void setLineJoint(const XLineJointItem* pItem) SAL_OVERRIDE; + virtual void setLineCap(const XLineCapItem* pItem) SAL_OVERRIDE; + +private: //ControllerItem sfx2::sidebar::ControllerItem maStyleControl; sfx2::sidebar::ControllerItem maDashControl; @@ -122,48 +109,10 @@ private: sfx2::sidebar::ControllerItem maEdgeStyle; sfx2::sidebar::ControllerItem maCapStyle; - std::unique_ptr<XLineStyleItem> mpStyleItem; - std::unique_ptr<XLineDashItem> mpDashItem; - - sal_uInt16 mnTrans; - SfxMapUnit meMapUnit; - sal_Int32 mnWidthCoreValue; - XLineEndListRef mxLineEndList; - XDashListRef mxLineStyleList; - std::unique_ptr<XLineStartItem> mpStartItem; - std::unique_ptr<XLineEndItem> mpEndItem; - - //popup windows - LineWidthPopup maLineWidthPopup; - - // images from resource - Image maIMGNone; - - // multi-images - std::unique_ptr<Image[]> mpIMGWidthIcon; - css::uno::Reference<css::frame::XFrame> mxFrame; SfxBindings* mpBindings; - /// bitfield - bool mbWidthValuable : 1; - void Initialize(); - void FillLineEndList(); - void FillLineStyleList(); - void SelectEndStyle(bool bStart); - void SelectLineStyle(); - void ActivateControls(); - - DECL_LINK(ChangeLineStyleHdl, void*); - DECL_LINK_TYPED(ToolboxWidthSelectHdl, ToolBox*, void); - DECL_LINK(ChangeTransparentHdl , void *); - DECL_LINK(ChangeStartHdl, void *); - DECL_LINK(ChangeEndHdl, void *); - DECL_LINK(ChangeEdgeStyleHdl, void *); - DECL_LINK(ChangeCapStyleHdl, void *); - - VclPtr<PopupControl> CreateLineWidthPopupControl (PopupContainer* pParent); }; } } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx new file mode 100644 index 000000000000..14ad854b5609 --- /dev/null +++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx @@ -0,0 +1,930 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include <sfx2/sidebar/ResourceDefinitions.hrc> +#include <sfx2/sidebar/Theme.hxx> +#include <sfx2/sidebar/ControlFactory.hxx> +#include <LinePropertyPanelBase.hxx> +#include <LinePropertyPanel.hrc> +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svx/xtable.hxx> +#include <svx/xdash.hxx> +#include <svx/drawitem.hxx> +#include <svx/svxitems.hrc> +#include <svtools/valueset.hxx> +#include <unotools/pathoptions.hxx> +#include <unotools/viewoptions.hxx> +#include <comphelper/processfactory.hxx> +#include <i18nlangtag/mslangid.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlndsit.hxx> +#include <vcl/svapp.hxx> +#include <svx/xlnwtit.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/toolbox.hxx> +#include <svx/xlntrit.hxx> +#include <svx/xlnstit.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xlncapit.hxx> +#include <svx/xlinjoit.hxx> +#include "svx/sidebar/PopupContainer.hxx" +#include "svx/sidebar/PopupControl.hxx" +#include "LineWidthControl.hxx" +#include <boost/bind.hpp> + +using namespace css; +using namespace css::uno; +using sfx2::sidebar::Theme; + +const char UNO_SELECTWIDTH[] = ".uno:SelectWidth"; + +namespace +{ + +void FillLineEndListBox(ListBox& rListBoxStart, ListBox& rListBoxEnd, const XLineEndList& rList) +{ + const sal_uInt32 nCount(rList.Count()); + const OUString sNone(SVX_RESSTR(RID_SVXSTR_NONE)); + + rListBoxStart.SetUpdateMode(false); + rListBoxEnd.SetUpdateMode(false); + + rListBoxStart.Clear(); + rListBoxEnd.Clear(); + + // add 'none' entries + rListBoxStart.InsertEntry(sNone); + rListBoxEnd.InsertEntry(sNone); + + for(sal_uInt32 i(0); i < nCount; i++) + { + XLineEndEntry* pEntry = rList.GetLineEnd(i); + const Bitmap aBitmap = const_cast< XLineEndList& >(rList).GetUiBitmap(i); + + if(!aBitmap.IsEmpty()) + { + Bitmap aCopyStart(aBitmap); + Bitmap aCopyEnd(aBitmap); + + const Size aBmpSize(aCopyStart.GetSizePixel()); + const Rectangle aCropRectStart(Point(), Size(aBmpSize.Width() / 2, aBmpSize.Height())); + const Rectangle aCropRectEnd(Point(aBmpSize.Width() / 2, 0), Size(aBmpSize.Width() / 2, aBmpSize.Height())); + + aCopyStart.Crop(aCropRectStart); + rListBoxStart.InsertEntry( + pEntry->GetName(), + Image(aCopyStart)); + + aCopyEnd.Crop(aCropRectEnd); + rListBoxEnd.InsertEntry( + pEntry->GetName(), + Image(aCopyEnd)); + } + else + { + rListBoxStart.InsertEntry(pEntry->GetName()); + rListBoxEnd.InsertEntry(pEntry->GetName()); + } + } + + rListBoxStart.SetUpdateMode(true); + rListBoxEnd.SetUpdateMode(true); +} + +void FillLineStyleListBox(ListBox& rListBox, const XDashList& rList) +{ + const sal_uInt32 nCount(rList.Count()); + rListBox.SetUpdateMode(false); + + rListBox.Clear(); + + // entry for 'none' + rListBox.InsertEntry(rList.GetStringForUiNoLine()); + + // entry for solid line + rListBox.InsertEntry(rList.GetStringForUiSolidLine(), + Image( rList.GetBitmapForUISolidLine())); + + for(sal_uInt32 i(0); i < nCount; i++) + { + XDashEntry* pEntry = rList.GetDash(i); + const Bitmap aBitmap = const_cast< XDashList& >(rList).GetUiBitmap(i); + + if(!aBitmap.IsEmpty()) + { + rListBox.InsertEntry(pEntry->GetName(), Image(aBitmap)); + } + else + { + rListBox.InsertEntry(pEntry->GetName()); + } + } + + rListBox.SetUpdateMode(true); +} + +} // end of anonymous namespace + +namespace svx { namespace sidebar { + +LinePropertyPanelBase::LinePropertyPanelBase( + vcl::Window* pParent, + const uno::Reference<frame::XFrame>& rxFrame) +: PanelLayout(pParent, "LinePropertyPanelBase", "svx/ui/sidebarline.ui", rxFrame), + mpStyleItem(), + mpDashItem(), + mnTrans(0), + meMapUnit(SFX_MAPUNIT_MM), + mnWidthCoreValue(0), + mpStartItem(), + mpEndItem(), + maLineWidthPopup(this, ::boost::bind(&LinePropertyPanelBase::CreateLineWidthPopupControl, this, _1)), + maIMGNone(SVX_RES(IMG_NONE_ICON)), + mpIMGWidthIcon(), + mxFrame(rxFrame), + mbWidthValuable(true) +{ + get(mpFTWidth, "widthlabel"); + get(mpTBWidth, "width"); + get(mpFTStyle, "stylelabel"); + get(mpLBStyle, "linestyle"); + get(mpFTTransparency, "translabel"); + get(mpMFTransparent, "linetransparency"); + get(mpFTArrow, "arrowlabel"); + get(mpLBStart, "beginarrowstyle"); + get(mpLBEnd, "endarrowstyle"); + get(mpFTEdgeStyle, "cornerlabel"); + get(mpLBEdgeStyle, "edgestyle"); + get(mpFTCapStyle, "caplabel"); + get(mpLBCapStyle, "linecapstyle"); + get(mpGridLineProps, "lineproperties"); + get(mpBoxArrowProps, "arrowproperties"); + + Initialize(); +} + +LinePropertyPanelBase::~LinePropertyPanelBase() +{ + disposeOnce(); +} + +void LinePropertyPanelBase::dispose() +{ + mpFTWidth.clear(); + mpTBWidth.clear(); + mpFTStyle.clear(); + mpLBStyle.clear(); + mpFTTransparency.clear(); + mpMFTransparent.clear(); + mpFTArrow.clear(); + mpLBStart.clear(); + mpLBEnd.clear(); + mpFTEdgeStyle.clear(); + mpLBEdgeStyle.clear(); + mpFTCapStyle.clear(); + mpLBCapStyle.clear(); + mpGridLineProps.clear(); + mpBoxArrowProps.clear(); + + PanelLayout::dispose(); +} + +void LinePropertyPanelBase::Initialize() +{ + mpIMGWidthIcon.reset(new Image[8]); + mpIMGWidthIcon[0] = Image(SVX_RES(IMG_WIDTH1_ICON)); + mpIMGWidthIcon[1] = Image(SVX_RES(IMG_WIDTH2_ICON)); + mpIMGWidthIcon[2] = Image(SVX_RES(IMG_WIDTH3_ICON)); + mpIMGWidthIcon[3] = Image(SVX_RES(IMG_WIDTH4_ICON)); + mpIMGWidthIcon[4] = Image(SVX_RES(IMG_WIDTH5_ICON)); + mpIMGWidthIcon[5] = Image(SVX_RES(IMG_WIDTH6_ICON)); + mpIMGWidthIcon[6] = Image(SVX_RES(IMG_WIDTH7_ICON)); + mpIMGWidthIcon[7] = Image(SVX_RES(IMG_WIDTH8_ICON)); + + // meMapUnit = maWidthControl.GetCoreMetric(); + + FillLineStyleList(); + SelectLineStyle(); + Link<> aLink = LINK( this, LinePropertyPanelBase, ChangeLineStyleHdl ); + mpLBStyle->SetSelectHdl( aLink ); + mpLBStyle->SetAccessibleName(OUString( "Style")); + mpLBStyle->AdaptDropDownLineCountToMaximum(); + + const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); + mpTBWidth->SetItemImage(nIdWidth, mpIMGWidthIcon[0]); + mpTBWidth->SetItemBits( nIdWidth, mpTBWidth->GetItemBits( nIdWidth ) | ToolBoxItemBits::DROPDOWNONLY ); + Link<ToolBox *, void> aLink2 = LINK(this, LinePropertyPanelBase, ToolboxWidthSelectHdl); + mpTBWidth->SetDropdownClickHdl ( aLink2 ); + mpTBWidth->SetSelectHdl ( aLink2 ); + + FillLineEndList(); + SelectEndStyle(true); + SelectEndStyle(false); + aLink = LINK( this, LinePropertyPanelBase, ChangeStartHdl ); + mpLBStart->SetSelectHdl( aLink ); + mpLBStart->SetAccessibleName(OUString("Beginning Style")); //wj acc + mpLBStart->AdaptDropDownLineCountToMaximum(); + aLink = LINK( this, LinePropertyPanelBase, ChangeEndHdl ); + mpLBEnd->SetSelectHdl( aLink ); + mpLBEnd->SetAccessibleName(OUString("Ending Style")); //wj acc + mpLBEnd->AdaptDropDownLineCountToMaximum(); + + aLink = LINK(this, LinePropertyPanelBase, ChangeTransparentHdl); + mpMFTransparent->SetModifyHdl(aLink); + mpMFTransparent->SetAccessibleName(OUString("Transparency")); //wj acc + + mpTBWidth->SetAccessibleRelationLabeledBy(mpFTWidth); + mpLBStyle->SetAccessibleRelationLabeledBy(mpFTStyle); + mpMFTransparent->SetAccessibleRelationLabeledBy(mpFTTransparency); + mpLBStart->SetAccessibleRelationLabeledBy(mpFTArrow); + mpLBEnd->SetAccessibleRelationLabeledBy(mpLBEnd); + + aLink = LINK( this, LinePropertyPanelBase, ChangeEdgeStyleHdl ); + mpLBEdgeStyle->SetSelectHdl( aLink ); + mpLBEdgeStyle->SetAccessibleName(OUString("Corner Style")); + + aLink = LINK( this, LinePropertyPanelBase, ChangeCapStyleHdl ); + mpLBCapStyle->SetSelectHdl( aLink ); + mpLBCapStyle->SetAccessibleName(OUString("Cap Style")); +} + +void LinePropertyPanelBase::DataChanged(const DataChangedEvent& /*rEvent*/) +{ +} + +void LinePropertyPanelBase::updateLineStyle(bool bDisabled, bool bSetOrDefault, const XLineStyleItem* pItem) +{ + if(bDisabled) + { + mpFTStyle->Disable(); + mpLBStyle->Disable(); + } + else + { + mpFTStyle->Enable(); + mpLBStyle->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + mpStyleItem.reset(static_cast<XLineStyleItem*>(pItem->Clone())); + } + } + else + { + mpStyleItem.reset(0); + } + + SelectLineStyle(); +} + +void LinePropertyPanelBase::updateLineDash(bool bDisabled, bool bSetOrDefault, const XLineDashItem* pItem) +{ + if(bDisabled) + { + mpFTStyle->Disable(); + mpLBStyle->Disable(); + } + else + { + mpFTStyle->Enable(); + mpLBStyle->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + mpDashItem.reset(static_cast<XLineDashItem*>(pItem->Clone())); + } + } + else + { + mpDashItem.reset(); + } + + SelectLineStyle(); +} + +void LinePropertyPanelBase::updateLineTransparence(bool bDisabled, bool bSetOrDefault, + const XLineTransparenceItem* pItem) +{ + if(bDisabled) + { + mpFTTransparency->Disable(); + mpMFTransparent->Disable(); + } + else + { + mpFTTransparency->Enable(); + mpMFTransparent->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + mnTrans = pItem->GetValue(); + mpMFTransparent->SetValue(mnTrans); + return; + } + } + + mpMFTransparent->SetValue(0);//add + mpMFTransparent->SetText(OUString()); +} + +void LinePropertyPanelBase::updateLineWidth(bool bDisabled, bool bSetOrDefault, + const XLineWidthItem* pItem) +{ + if(bDisabled) + { + mpTBWidth->Disable(); + mpFTWidth->Disable(); + } + else + { + mpTBWidth->Enable(); + mpFTWidth->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + mnWidthCoreValue = pItem->GetValue(); + mbWidthValuable = true; + SetWidthIcon(); + return; + } + } + + mbWidthValuable = false; + SetWidthIcon(); +} + +void LinePropertyPanelBase::updateLineStart(bool bDisabled, bool bSetOrDefault, + const XLineStartItem* pItem) +{ + if(bDisabled) + { + mpFTArrow->Disable(); + mpLBStart->Disable(); + } + else + { + mpFTArrow->Enable(); + mpLBStart->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + mpStartItem.reset(static_cast<XLineStartItem*>(pItem->Clone())); + SelectEndStyle(true); + return; + } + } + + mpStartItem.reset(0); + SelectEndStyle(true); +} + +void LinePropertyPanelBase::updateLineEnd(bool bDisabled, bool bSetOrDefault, + const XLineEndItem* pItem) +{ + if(bDisabled) + { + mpFTArrow->Disable(); + mpLBEnd->Disable(); + } + else + { + mpFTArrow->Enable(); + mpLBEnd->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + mpEndItem.reset(static_cast<XLineEndItem*>(pItem->Clone())); + SelectEndStyle(false); + return; + } + } + + mpEndItem.reset(0); + SelectEndStyle(false); +} + +void LinePropertyPanelBase::updateLineJoint(bool bDisabled, bool bSetOrDefault, + const XLineJointItem* pItem) +{ + if(bDisabled) + { + mpLBEdgeStyle->Disable(); + mpFTEdgeStyle->Disable(); + } + else + { + mpLBEdgeStyle->Enable(); + mpFTEdgeStyle->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + sal_Int32 nEntryPos(0); + + switch(pItem->GetValue()) + { + case drawing::LineJoint_MIDDLE: + case drawing::LineJoint_ROUND: + { + nEntryPos = 1; + break; + } + case drawing::LineJoint_NONE: + { + nEntryPos = 2; + break; + } + case drawing::LineJoint_MITER: + { + nEntryPos = 3; + break; + } + case drawing::LineJoint_BEVEL: + { + nEntryPos = 4; + break; + } + + default: + break; + } + + if(nEntryPos) + { + mpLBEdgeStyle->SelectEntryPos(nEntryPos - 1); + return; + } + } + } + + mpLBEdgeStyle->SetNoSelection(); +} + +void LinePropertyPanelBase::updateLineCap(bool bDisabled, bool bSetOrDefault, + const XLineCapItem* pItem) +{ + if(bDisabled) + { + mpLBCapStyle->Disable(); + mpFTCapStyle->Disable(); + } + else + { + mpLBCapStyle->Enable(); + mpLBCapStyle->Enable(); + } + + if(bSetOrDefault) + { + if(pItem) + { + sal_Int32 nEntryPos(0); + + switch(pItem->GetValue()) + { + case drawing::LineCap_BUTT: + { + nEntryPos = 1; + break; + } + case drawing::LineCap_ROUND: + { + nEntryPos = 2; + break; + } + case drawing::LineCap_SQUARE: + { + nEntryPos = 3; + break; + } + + default: + break; + } + + if(nEntryPos) + { + mpLBCapStyle->SelectEntryPos(nEntryPos - 1); + return; + } + } + } + + mpLBCapStyle->SetNoSelection(); +} + +IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeLineStyleHdl) +{ + const sal_Int32 nPos(mpLBStyle->GetSelectEntryPos()); + + if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBStyle->IsValueChangedFromSaved()) + { + if(0 == nPos) + { + // drawing::LineStyle_NONE + const XLineStyleItem aItem(drawing::LineStyle_NONE); + + setLineStyle(aItem); + } + else if(1 == nPos) + { + // drawing::LineStyle_SOLID + const XLineStyleItem aItem(drawing::LineStyle_SOLID); + + setLineStyle(aItem); + } + else if (mxLineStyleList.is() && mxLineStyleList->Count() > (long)(nPos - 2)) + { + // drawing::LineStyle_DASH + const XLineStyleItem aItemA(drawing::LineStyle_DASH); + const XDashEntry* pDashEntry = mxLineStyleList->GetDash(nPos - 2); + OSL_ENSURE(pDashEntry, "OOps, got empty XDash from XDashList (!)"); + const XLineDashItem aItemB( + pDashEntry ? pDashEntry->GetName() : OUString(), + pDashEntry ? pDashEntry->GetDash() : XDash()); + + setLineStyle(aItemA); + setLineDash(aItemB); + } + } + + ActivateControls(); + return 0; +} + +IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeStartHdl) +{ + sal_Int32 nPos = mpLBStart->GetSelectEntryPos(); + if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBStart->IsValueChangedFromSaved() ) + { + std::unique_ptr<XLineStartItem> pItem; + if( nPos == 0 ) + pItem.reset(new XLineStartItem()); + else if( mxLineEndList.is() && mxLineEndList->Count() > (long) ( nPos - 1 ) ) + pItem.reset(new XLineStartItem( mpLBStart->GetSelectEntry(),mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() )); + setLineStartStyle(pItem.get()); + } + return 0; +} + +IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeEndHdl) +{ + sal_Int32 nPos = mpLBEnd->GetSelectEntryPos(); + if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBEnd->IsValueChangedFromSaved() ) + { + std::unique_ptr<XLineEndItem> pItem; + if( nPos == 0 ) + pItem.reset(new XLineEndItem()); + else if( mxLineEndList.is() && mxLineEndList->Count() > (long) ( nPos - 1 ) ) + pItem.reset(new XLineEndItem( mpLBEnd->GetSelectEntry(), mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() )); + setLineEndStyle(pItem.get()); + } + return 0; +} + +IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeEdgeStyleHdl) +{ + const sal_Int32 nPos(mpLBEdgeStyle->GetSelectEntryPos()); + + if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBEdgeStyle->IsValueChangedFromSaved()) + { + std::unique_ptr<XLineJointItem> pItem; + + switch(nPos) + { + case 0: // rounded + { + pItem.reset(new XLineJointItem(drawing::LineJoint_ROUND)); + break; + } + case 1: // none + { + pItem.reset(new XLineJointItem(drawing::LineJoint_NONE)); + break; + } + case 2: // mitered + { + pItem.reset(new XLineJointItem(drawing::LineJoint_MITER)); + break; + } + case 3: // beveled + { + pItem.reset(new XLineJointItem(drawing::LineJoint_BEVEL)); + break; + } + } + + setLineJoint(pItem.get()); + } + return 0; +} + +IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeCapStyleHdl) +{ + const sal_Int32 nPos(mpLBCapStyle->GetSelectEntryPos()); + + if(LISTBOX_ENTRY_NOTFOUND != nPos && mpLBCapStyle->IsValueChangedFromSaved()) + { + std::unique_ptr<XLineCapItem> pItem; + + switch(nPos) + { + case 0: // flat + { + pItem.reset(new XLineCapItem(drawing::LineCap_BUTT)); + break; + } + case 1: // round + { + pItem.reset(new XLineCapItem(drawing::LineCap_ROUND)); + break; + } + case 2: // square + { + pItem.reset(new XLineCapItem(drawing::LineCap_SQUARE)); + break; + } + } + + setLineCap(pItem.get()); + } + return 0; +} + +IMPL_LINK_TYPED(LinePropertyPanelBase, ToolboxWidthSelectHdl,ToolBox*, pToolBox, void) +{ + if (pToolBox->GetItemCommand(pToolBox->GetCurItemId()) == UNO_SELECTWIDTH) + { + maLineWidthPopup.SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit); + maLineWidthPopup.Show(*pToolBox); + } +} + +IMPL_LINK_NOARG( LinePropertyPanelBase, ChangeTransparentHdl ) +{ + sal_uInt16 nVal = (sal_uInt16)mpMFTransparent->GetValue(); + XLineTransparenceItem aItem( nVal ); + + setLineTransparency(aItem); + return 0L; +} + +VclPtr<PopupControl> LinePropertyPanelBase::CreateLineWidthPopupControl (PopupContainer* pParent) +{ + return VclPtrInstance<LineWidthControl>(pParent, *this); +} + +void LinePropertyPanelBase::EndLineWidthPopupMode() +{ + maLineWidthPopup.Hide(); +} + +void LinePropertyPanelBase::SetWidthIcon(int n) +{ + const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); + if (n == 0) + mpTBWidth->SetItemImage( nIdWidth, maIMGNone); + else + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[n-1]); +} + +void LinePropertyPanelBase::SetWidthIcon() +{ + if(!mbWidthValuable) + { + const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); + mpTBWidth->SetItemImage(nIdWidth, maIMGNone); + return; + } + + long nVal = LogicToLogic(mnWidthCoreValue * 10,(MapUnit)meMapUnit , MAP_POINT); + const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); + + if(nVal <= 6) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[0]); + else if(nVal > 6 && nVal <= 9) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[1]); + else if(nVal > 9 && nVal <= 12) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[2]); + else if(nVal > 12 && nVal <= 19) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[3]); + else if(nVal > 19 && nVal <= 26) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[4]); + else if(nVal > 26 && nVal <= 37) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[5]); + else if(nVal > 37 && nVal <=52) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[6]); + else if(nVal > 52) + mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[7]); + +} + +void LinePropertyPanelBase::SetWidth(long nWidth) +{ + mnWidthCoreValue = nWidth; + mbWidthValuable = true; +} + +void LinePropertyPanelBase::FillLineEndList() +{ + SfxObjectShell* pSh = SfxObjectShell::Current(); + if ( pSh && pSh->GetItem( SID_LINEEND_LIST ) ) + { + mpLBStart->Enable(); + SvxLineEndListItem aItem( *static_cast<const SvxLineEndListItem*>(pSh->GetItem( SID_LINEEND_LIST ) ) ); + mxLineEndList = aItem.GetLineEndList(); + + if (mxLineEndList.is()) + { + FillLineEndListBox(*mpLBStart, *mpLBEnd, *mxLineEndList); + } + + mpLBStart->SelectEntryPos(0); + mpLBEnd->SelectEntryPos(0); + } + else + { + mpLBStart->Disable(); + mpLBEnd->Disable(); + } +} + +void LinePropertyPanelBase::FillLineStyleList() +{ + SfxObjectShell* pSh = SfxObjectShell::Current(); + if ( pSh && pSh->GetItem( SID_DASH_LIST ) ) + { + mpLBStyle->Enable(); + SvxDashListItem aItem( *static_cast<const SvxDashListItem*>(pSh->GetItem( SID_DASH_LIST ) ) ); + mxLineStyleList = aItem.GetDashList(); + + if (mxLineStyleList.is()) + { + FillLineStyleListBox(*mpLBStyle, *mxLineStyleList); + } + + mpLBStyle->SelectEntryPos(0); + } + else + { + mpLBStyle->Disable(); + } +} + +void LinePropertyPanelBase::SelectLineStyle() +{ + if( !mpStyleItem.get() || !mpDashItem.get() ) + { + mpLBStyle->SetNoSelection(); + mpLBStyle->Disable(); + return; + } + + const drawing::LineStyle eXLS(mpStyleItem ? (drawing::LineStyle)mpStyleItem->GetValue() : drawing::LineStyle_NONE); + bool bSelected(false); + + switch(eXLS) + { + case drawing::LineStyle_NONE: + break; + case drawing::LineStyle_SOLID: + mpLBStyle->SelectEntryPos(1); + bSelected = true; + break; + default: + if(mpDashItem && mxLineStyleList.is()) + { + const XDash& rDash = mpDashItem->GetDashValue(); + for(sal_Int32 a(0);!bSelected && a < mxLineStyleList->Count(); a++) + { + XDashEntry* pEntry = mxLineStyleList->GetDash(a); + const XDash& rEntry = pEntry->GetDash(); + if(rDash == rEntry) + { + mpLBStyle->SelectEntryPos(a + 2); + bSelected = true; + } + } + } + break; + } + + if(!bSelected) + mpLBStyle->SelectEntryPos( 0 ); +} + +void LinePropertyPanelBase::SelectEndStyle(bool bStart) +{ + bool bSelected(false); + + if(bStart) + { + if( !mpStartItem.get() ) + { + mpLBStart->SetNoSelection(); + mpLBStart->Disable(); + return; + } + + if (mpStartItem && mxLineEndList.is()) + { + const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue(); + for(sal_Int32 a(0);!bSelected && a < mxLineEndList->Count(); a++) + { + XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a); + const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); + if(rItemPolygon == rEntryPolygon) + { + mpLBStart->SelectEntryPos(a + 1); + bSelected = true; + } + } + } + + if(!bSelected) + { + mpLBStart->SelectEntryPos( 0 ); + } + } + else + { + if( !mpEndItem.get() ) + { + mpLBEnd->SetNoSelection(); + mpLBEnd->Disable(); + return; + } + + if (mpEndItem && mxLineEndList.is()) + { + const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue(); + for(sal_Int32 a(0);!bSelected && a < mxLineEndList->Count(); a++) + { + XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a); + const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); + if(rItemPolygon == rEntryPolygon) + { + mpLBEnd->SelectEntryPos(a + 1); + bSelected = true; + } + } + } + + if(!bSelected) + { + mpLBEnd->SelectEntryPos( 0 ); + } + } +} + +void LinePropertyPanelBase::ActivateControls() +{ + const sal_Int32 nPos(mpLBStyle->GetSelectEntryPos()); + bool bLineStyle( nPos != 0 ); + + mpGridLineProps->Enable( bLineStyle ); + mpBoxArrowProps->Enable( bLineStyle ); +} + +}} // end of namespace svx::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.hxx b/svx/source/sidebar/line/LinePropertyPanelBase.hxx new file mode 100644 index 000000000000..e5dd0d9897e1 --- /dev/null +++ b/svx/source/sidebar/line/LinePropertyPanelBase.hxx @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_LINE_LINEPROPERTYPANELBASE_HXX +#define INCLUDED_SVX_SOURCE_SIDEBAR_LINE_LINEPROPERTYPANELBASE_HXX + +#include <svx/xdash.hxx> +#include <vcl/ctrl.hxx> +#include <sfx2/sidebar/SidebarPanelBase.hxx> +#include <sfx2/sidebar/ControllerItem.hxx> +#include <vcl/fixed.hxx> +#include <vcl/field.hxx> +#include <vcl/layout.hxx> +#include <memory> +#include <svx/sidebar/PanelLayout.hxx> +#include <svx/xtable.hxx> +#include "LineWidthPopup.hxx" + + +class XLineStyleItem; +class XLineDashItem; +class XLineStartItem; +class XLineWidthItem; +class XLineEndItem; +class XLineEndList; +class XLineJointItem; +class XLineCapItem; +class XLineTransparenceItem; +class XDashList; +class ListBox; +class ToolBox; +class FloatingWindow; + +namespace +{ + +#define SIDEBAR_LINE_WIDTH_GLOBAL_VALUE "PopupPanel_LineWidth" + +} //end of anonymous namespace + +namespace svx +{ +namespace sidebar +{ + +class PopupContainer; +class LineWidthControl; + +class LinePropertyPanelBase : public PanelLayout +{ +public: + virtual ~LinePropertyPanelBase(); + virtual void dispose() SAL_OVERRIDE; + + virtual void DataChanged( + const DataChangedEvent& rEvent) SAL_OVERRIDE; + + void SetWidth(long nWidth); + void SetWidthIcon(int n); + void SetWidthIcon(); + + void EndLineWidthPopupMode(); + + // constructor/destuctor + LinePropertyPanelBase( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + virtual void setLineWidth(const XLineWidthItem& rItem) = 0; + +protected: + + virtual void setLineStyle(const XLineStyleItem& rItem) = 0; + virtual void setLineDash(const XLineDashItem& rItem) = 0; + virtual void setLineEndStyle(const XLineEndItem* pItem) = 0; + virtual void setLineStartStyle(const XLineStartItem* pItem) = 0; + virtual void setLineTransparency(const XLineTransparenceItem& rItem) = 0; + virtual void setLineJoint(const XLineJointItem* pItem) = 0; + virtual void setLineCap(const XLineCapItem* pItem) = 0; + + + void updateLineStyle(bool bDisabled, bool bSetOrDefault, const XLineStyleItem* pItem); + void updateLineDash(bool bDisabled, bool bSetOrDefault, const XLineDashItem* pItem); + void updateLineTransparence(bool bDisabled, bool bSetOrDefault, const XLineTransparenceItem* pItem); + void updateLineWidth(bool bDisabled, bool bSetOrDefault, const XLineWidthItem* pItem); + void updateLineStart(bool bDisabled, bool bSetOrDefault, const XLineStartItem* pItem); + void updateLineEnd(bool bDisabled, bool bSetOrDefault, const XLineEndItem* pItem); + void updateLineJoint(bool bDisabled, bool bSetOrDefault, const XLineJointItem* pItem); + void updateLineCap(bool bDisabled, bool bSetOrDefault, const XLineCapItem* pItem); + + void FillLineEndList(); + void FillLineStyleList(); + void SelectEndStyle(bool bStart); + void SelectLineStyle(); + void ActivateControls(); + +private: + //ui controls + VclPtr<FixedText> mpFTWidth; + VclPtr<ToolBox> mpTBWidth; + VclPtr<FixedText> mpFTStyle; + VclPtr<ListBox> mpLBStyle; + VclPtr<FixedText> mpFTTransparency; + VclPtr<MetricField> mpMFTransparent; + VclPtr<FixedText> mpFTArrow; + VclPtr<ListBox> mpLBStart; + VclPtr<ListBox> mpLBEnd; + VclPtr<FixedText> mpFTEdgeStyle; + VclPtr<ListBox> mpLBEdgeStyle; + VclPtr<FixedText> mpFTCapStyle; + VclPtr<ListBox> mpLBCapStyle; + VclPtr<VclGrid> mpGridLineProps; + VclPtr<VclVBox> mpBoxArrowProps; + + std::unique_ptr<XLineStyleItem> mpStyleItem; + std::unique_ptr<XLineDashItem> mpDashItem; + + sal_uInt16 mnTrans; + SfxMapUnit meMapUnit; + sal_Int32 mnWidthCoreValue; + XLineEndListRef mxLineEndList; + XDashListRef mxLineStyleList; + std::unique_ptr<XLineStartItem> mpStartItem; + std::unique_ptr<XLineEndItem> mpEndItem; + + //popup windows + LineWidthPopup maLineWidthPopup; + + // images from resource + Image maIMGNone; + + // multi-images + std::unique_ptr<Image[]> mpIMGWidthIcon; + + css::uno::Reference<css::frame::XFrame> mxFrame; + + /// bitfield + bool mbWidthValuable : 1; + + void Initialize(); + + DECL_LINK(ChangeLineStyleHdl, void*); + DECL_LINK_TYPED(ToolboxWidthSelectHdl, ToolBox*, void); + DECL_LINK(ChangeTransparentHdl , void *); + DECL_LINK(ChangeStartHdl, void *); + DECL_LINK(ChangeEndHdl, void *); + DECL_LINK(ChangeEdgeStyleHdl, void *); + DECL_LINK(ChangeCapStyleHdl, void *); + + VclPtr<PopupControl> CreateLineWidthPopupControl (PopupContainer* pParent); +}; + +} } // end of namespace svx::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LineWidthControl.cxx b/svx/source/sidebar/line/LineWidthControl.cxx index 7d026fdf596d..2bee185dbdaa 100644 --- a/svx/source/sidebar/line/LineWidthControl.cxx +++ b/svx/source/sidebar/line/LineWidthControl.cxx @@ -18,7 +18,7 @@ */ #include "LineWidthControl.hxx" #include "LinePropertyPanel.hrc" -#include "LinePropertyPanel.hxx" +#include "LinePropertyPanelBase.hxx" #include <svx/dialogs.hrc> #include <svx/dialmgr.hxx> @@ -36,10 +36,9 @@ namespace svx { namespace sidebar { LineWidthControl::LineWidthControl ( vcl::Window* pParent, - LinePropertyPanel& rPanel) + LinePropertyPanelBase& rPanel) : svx::sidebar::PopupControl(pParent,SVX_RES(RID_POPUPPANEL_LINEPAGE_WIDTH)), mrLinePropertyPanel(rPanel), - mpBindings(NULL), maVSWidth(VclPtr<LineWidthValueSet>::Create(this, SVX_RES(VS_WIDTH))), maFTCus( VclPtr<FixedText>::Create(this, SVX_RES(FT_CUSTOME))), maFTWidth( VclPtr<FixedText>::Create(this, SVX_RES(FT_LINE_WIDTH))), @@ -57,7 +56,6 @@ LineWidthControl::LineWidthControl ( { Initialize(); FreeResource(); - mpBindings = mrLinePropertyPanel.GetBindings(); } LineWidthControl::~LineWidthControl() @@ -268,7 +266,7 @@ IMPL_LINK(LineWidthControl, VSSelectHdl, void *, pControl) sal_IntPtr nVal = LogicToLogic(reinterpret_cast<sal_IntPtr>(maVSWidth->GetItemData( iPos )), MAP_POINT, (MapUnit)meMapUnit); nVal = maMFWidth->Denormalize(nVal); XLineWidthItem aWidthItem( nVal ); - mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_WIDTH, SfxCallMode::RECORD, &aWidthItem, 0L); + mrLinePropertyPanel.setLineWidth(aWidthItem); mrLinePropertyPanel.SetWidthIcon(iPos); mrLinePropertyPanel.SetWidth(nVal); mbCloseByEdit = false; @@ -282,7 +280,7 @@ IMPL_LINK(LineWidthControl, VSSelectHdl, void *, pControl) long nVal = LogicToLogic(mnCustomWidth , MAP_POINT, (MapUnit)meMapUnit); nVal = maMFWidth->Denormalize(nVal); XLineWidthItem aWidthItem( nVal ); - mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_WIDTH, SfxCallMode::RECORD, &aWidthItem, 0L); + mrLinePropertyPanel.setLineWidth(aWidthItem); mrLinePropertyPanel.SetWidth(nVal); mbCloseByEdit = false; mnTmpCustomWidth = 0; @@ -319,7 +317,7 @@ IMPL_LINK(LineWidthControl, MFModifyHdl, void *, pControl) long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)meMapUnit ); sal_Int32 nNewWidth = (short)maMFWidth->Denormalize( nVal ); XLineWidthItem aWidthItem(nNewWidth); - mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_WIDTH, SfxCallMode::RECORD, &aWidthItem, 0L); + mrLinePropertyPanel.setLineWidth(aWidthItem); mbCloseByEdit = true; mnTmpCustomWidth = nTmp; diff --git a/svx/source/sidebar/line/LineWidthControl.hxx b/svx/source/sidebar/line/LineWidthControl.hxx index 0b14574d995d..4a2874969c83 100644 --- a/svx/source/sidebar/line/LineWidthControl.hxx +++ b/svx/source/sidebar/line/LineWidthControl.hxx @@ -30,12 +30,12 @@ class SfxBindings; namespace svx { namespace sidebar { -class LinePropertyPanel; +class LinePropertyPanelBase; class LineWidthControl : public svx::sidebar::PopupControl { public: - LineWidthControl (vcl::Window* pParent, LinePropertyPanel& rPanel); + LineWidthControl (vcl::Window* pParent, LinePropertyPanelBase& rPanel); virtual ~LineWidthControl(); virtual void dispose() SAL_OVERRIDE; @@ -53,8 +53,7 @@ public: } private: - LinePropertyPanel& mrLinePropertyPanel; - SfxBindings* mpBindings; + LinePropertyPanelBase& mrLinePropertyPanel; VclPtr<LineWidthValueSet> maVSWidth; VclPtr<FixedText> maFTCus; VclPtr<FixedText> maFTWidth; |