diff options
author | Susobhan Ghosh <susobhang70@gmail.com> | 2016-06-20 23:24:51 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-06-21 20:48:10 +0000 |
commit | 1bbf0612ea35c73adf0c2aabedf457f7d85acdc0 (patch) | |
tree | 1793b890a2c64f4530eb20cfff09abab93d6e493 | |
parent | 1d852cd65709f1d0cbed64f906291b7641f4dde6 (diff) |
tdf#90078 Add import bitmap button to Area Panel
Change-Id: I49712f807d38a614fd707d06c9453545360db89f
Reviewed-on: https://gerrit.libreoffice.org/26527
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | include/svx/sidebar/AreaPropertyPanelBase.hxx | 3 | ||||
-rw-r--r-- | svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 126 | ||||
-rw-r--r-- | svx/uiconfig/ui/sidebararea.ui | 153 |
3 files changed, 205 insertions, 77 deletions
diff --git a/include/svx/sidebar/AreaPropertyPanelBase.hxx b/include/svx/sidebar/AreaPropertyPanelBase.hxx index fc24c928ce0a..525199e3523d 100644 --- a/include/svx/sidebar/AreaPropertyPanelBase.hxx +++ b/include/svx/sidebar/AreaPropertyPanelBase.hxx @@ -136,6 +136,8 @@ protected: VclPtr<ToolBox> mpBTNGradient; VclPtr<MetricField> mpMTRAngle; VclPtr<ListBox> mpGradientStyle; + VclPtr<SvxFillAttrBox> mpLbFillBitmap; + VclPtr<PushButton> mpBmpImport; std::unique_ptr< XFillStyleItem > mpStyleItem; std::unique_ptr< XFillColorItem > mpColorItem; @@ -165,6 +167,7 @@ protected: DECL_LINK_TYPED(ChangeTrgrTypeHdl_Impl, ListBox&, void); DECL_LINK_TYPED(ModifyTransparentHdl_Impl, Edit&, void); DECL_LINK_TYPED(ModifyTransSliderHdl, Slider*, void); + DECL_LINK_TYPED(ClickImportBitmapHdl, Button*, void); // for transparency gradient VclPtr<PopupControl> CreateTransparencyGradientControl (PopupContainer* pParent); diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index 350387b4047d..65be70b7b933 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -39,7 +39,7 @@ #include <vcl/toolbox.hxx> #include <svtools/toolbarmenu.hxx> #include <svx/tbcontrl.hxx> - +#include "sfx2/opengrf.hxx" using namespace css; using namespace css::uno; @@ -100,6 +100,8 @@ AreaPropertyPanelBase::AreaPropertyPanelBase( get(mpLbFillGradFrom, "fillgrad1"); get(mpLbFillGradTo, "fillgrad2"); get(mpGradientStyle, "gradientstyle"); + get(mpLbFillBitmap, "fillbitmap"); + get(mpBmpImport, "bmpimport"); Initialize(); } @@ -124,6 +126,8 @@ void AreaPropertyPanelBase::dispose() mpLbFillGradFrom.clear(); mpLbFillGradTo.clear(); mpGradientStyle.clear(); + mpLbFillBitmap.clear(); + mpBmpImport.clear(); PanelLayout::dispose(); } @@ -161,6 +165,7 @@ void AreaPropertyPanelBase::Initialize() mpGradientStyle->SetSelectHdl( aLink ); mpLbFillGradFrom->SetSelectHdl( aLink ); mpLbFillGradTo->SetSelectHdl( aLink ); + mpLbFillBitmap->SetSelectHdl( aLink ); mpMTRAngle->SetModifyHdl(LINK(this,AreaPropertyPanelBase, ChangeGradientAngle)); mpLBTransType->SetSelectHdl(LINK(this, AreaPropertyPanelBase, ChangeTrgrTypeHdl_Impl)); @@ -176,6 +181,7 @@ void AreaPropertyPanelBase::Initialize() mpBTNGradient->SetSelectHdl( aLink2 ); mpBTNGradient->SetItemImage(nIdGradient,maImgLinear); mpBTNGradient->Hide(); + mpBmpImport->SetClickHdl( LINK(this, AreaPropertyPanelBase, ClickImportBitmapHdl)); mpSidebarController = sfx2::sidebar::SidebarController::GetSidebarControllerForFrame(mxFrame); mpSidebarController->NotifyResize(); } @@ -186,6 +192,49 @@ void AreaPropertyPanelBase::SetTransparency(sal_uInt16 nVal) mpMTRTransparent->SetValue(nVal); } +IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, ClickImportBitmapHdl, Button*, void) +{ + SvxOpenGraphicDialog aDlg( "Import" ); + aDlg.EnableLink(false); + if( aDlg.Execute() == GRFILTER_OK ) + { + Graphic aGraphic; + EnterWait(); + int nError = aDlg.GetGraphic( aGraphic ); + LeaveWait(); + if( nError == GRFILTER_OK ) + { + const SvxBitmapListItem aItem( *static_cast<const SvxBitmapListItem*>(SfxObjectShell::Current()->GetItem(SID_BITMAP_LIST))); + XBitmapListRef pList = aItem.GetBitmapList(); + INetURLObject aURL( aDlg.GetPath() ); + OUString aFileName = aURL.GetName().getToken( 0, '.' ); + OUString aName = aFileName; + long j = 1; + bool bValidBitmapName = false; + while( !bValidBitmapName ) + { + bValidBitmapName = true; + for( long i = 0; i < pList->Count() && bValidBitmapName; i++ ) + { + if( aName == pList->GetBitmap(i)->GetName() ) + { + bValidBitmapName = false; + aName = aFileName + OUString::number(j++); + } + } + } + + XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName ); + pList->Insert(pEntry); + pList->Save(); + mpLbFillBitmap->Clear(); + mpLbFillBitmap->Fill(pList); + mpLbFillBitmap->SelectEntry(aName); + SelectFillAttrHdl(*mpLbFillBitmap); + } + } +} + IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) { const drawing::FillStyle eXFS = (drawing::FillStyle)mpLbFillType->GetSelectEntryPos(); @@ -211,6 +260,8 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) mpGradientStyle->Hide(); mpMTRAngle->Hide(); mpToolBoxColor->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); mpLbFillType->Selected(); mpLbFillAttr->Disable(); @@ -225,6 +276,8 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) mpLbFillGradTo->Hide(); mpGradientStyle->Hide(); mpMTRAngle->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); mpToolBoxColor->Show(); const OUString aTmpStr; const Color aColor = mpColorItem ? mpColorItem->GetColorValue() : COL_AUTO; @@ -242,6 +295,8 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) mpGradientStyle->Show(); mpMTRAngle->Show(); mpToolBoxColor->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); const SvxColorListItem* pColorListItem = static_cast<const SvxColorListItem*>(pSh ? pSh->GetItem(SID_COLOR_TABLE) : nullptr); if (pColorListItem) @@ -308,6 +363,8 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) mpMTRAngle->Hide(); mpGradientStyle->Hide(); mpToolBoxColor->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); if(pSh && pSh->GetItem(SID_HATCH_LIST)) { @@ -344,24 +401,25 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) } case drawing::FillStyle_BITMAP: { - mpLbFillAttr->Show(); + mpLbFillAttr->Hide(); mpLbFillGradFrom->Hide(); mpLbFillGradTo->Hide(); mpMTRAngle->Hide(); mpGradientStyle->Hide(); mpToolBoxColor->Hide(); + mpLbFillBitmap->Show(); + mpBmpImport->Show(); if(pSh && pSh->GetItem(SID_BITMAP_LIST)) { - if(!mpLbFillAttr->GetEntryCount()) + if(!mpLbFillBitmap->GetEntryCount()) { const SvxBitmapListItem aItem( *static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST))); - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(aItem.GetBitmapList()); + mpLbFillBitmap->Clear(); + mpLbFillBitmap->Fill(aItem.GetBitmapList()); } - mpLbFillAttr->AdaptDropDownLineCountToMaximum(); + mpLbFillBitmap->AdaptDropDownLineCountToMaximum(); if(LISTBOX_ENTRY_NOTFOUND != mnLastPosBitmap) { @@ -370,17 +428,17 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) if(mnLastPosBitmap < aItem.GetBitmapList()->Count()) { const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(mnLastPosBitmap); - const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); + const XFillBitmapItem aXFillBitmapItem(mpLbFillBitmap->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); // #i122676# change FillStyle and Bitmap in one call setFillStyleAndBitmap(&aXFillStyleItem, aXFillBitmapItem); - mpLbFillAttr->SelectEntryPos(mnLastPosBitmap); + mpLbFillBitmap->SelectEntryPos(mnLastPosBitmap); } } } else { - mpLbFillAttr->Disable(); + mpLbFillBitmap->Hide(); } break; } @@ -488,7 +546,7 @@ void AreaPropertyPanelBase::SelectFillAttrHdl_Impl() } case drawing::FillStyle_BITMAP: { - sal_Int32 nPos = mpLbFillAttr->GetSelectEntryPos(); + sal_Int32 nPos = mpLbFillBitmap->GetSelectEntryPos(); if(LISTBOX_ENTRY_NOTFOUND == nPos) { @@ -502,7 +560,7 @@ void AreaPropertyPanelBase::SelectFillAttrHdl_Impl() if(nPos < aItem.GetBitmapList()->Count()) { const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos); - const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); + const XFillBitmapItem aXFillBitmapItem(mpLbFillBitmap->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); // #i122676# Change FillStyle and Bitmap in one call setFillStyleAndBitmap(bFillStyleChange ? &aXFillStyleItem : nullptr, aXFillBitmapItem); @@ -840,22 +898,20 @@ void AreaPropertyPanelBase::updateFillBitmap(bool bDisabled, bool bDefault, cons if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue()) { - mpLbFillAttr->Show(); + mpLbFillBitmap->Show(); mpToolBoxColor->Hide(); if(bDefault) { - mpLbFillAttr->Enable(); Update(); } else if(bDisabled) { - mpLbFillAttr->Disable(); - mpLbFillAttr->SetNoSelection(); + mpLbFillBitmap->Hide(); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillBitmap->SetNoSelection(); } } mpSidebarController->NotifyResize(); @@ -963,14 +1019,14 @@ void AreaPropertyPanelBase::NotifyItemUpdate( const SfxObjectShell* pSh = SfxObjectShell::Current(); const SvxBitmapListItem aItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST))); - mpLbFillAttr->Clear(); - mpLbFillAttr->Enable(); - mpLbFillAttr->Fill(aItem.GetBitmapList()); - mpLbFillAttr->SelectEntry(aString); + mpLbFillBitmap->Clear(); + mpLbFillBitmap->Show(); + mpLbFillBitmap->Fill(aItem.GetBitmapList()); + mpLbFillBitmap->SelectEntry(aString); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillBitmap->SetNoSelection(); } } } @@ -996,6 +1052,8 @@ void AreaPropertyPanelBase::Update() mpMTRAngle->Hide(); mpGradientStyle->Hide(); mpToolBoxColor->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); break; } case drawing::FillStyle_SOLID: @@ -1008,6 +1066,8 @@ void AreaPropertyPanelBase::Update() mpMTRAngle->Hide(); mpGradientStyle->Hide(); mpToolBoxColor->Show(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); } break; } @@ -1020,6 +1080,8 @@ void AreaPropertyPanelBase::Update() mpMTRAngle->Show(); mpGradientStyle->Show(); mpToolBoxColor->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) { @@ -1074,6 +1136,10 @@ void AreaPropertyPanelBase::Update() mpMTRAngle->Hide(); mpGradientStyle->Hide(); mpToolBoxColor->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); + mpLbFillBitmap->Hide(); + mpBmpImport->Hide(); if(pSh && pSh->GetItem(SID_HATCH_LIST)) { @@ -1101,34 +1167,35 @@ void AreaPropertyPanelBase::Update() } case drawing::FillStyle_BITMAP: { - mpLbFillAttr->Show(); + mpLbFillAttr->Hide(); mpToolBoxColor->Hide(); mpLbFillGradFrom->Hide(); mpLbFillGradTo->Hide(); mpMTRAngle->Hide(); mpGradientStyle->Hide(); + mpLbFillBitmap->Show(); + mpBmpImport->Show(); if(pSh && pSh->GetItem(SID_BITMAP_LIST)) { const SvxBitmapListItem aItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST))); - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(aItem.GetBitmapList()); + mpLbFillBitmap->Clear(); + mpLbFillBitmap->Fill(aItem.GetBitmapList()); if(mpBitmapItem) { const OUString aString(mpBitmapItem->GetName()); - mpLbFillAttr->SelectEntry(aString); + mpLbFillBitmap->SelectEntry(aString); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillBitmap->SetNoSelection(); } } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillBitmap->SetNoSelection(); } break; } @@ -1136,6 +1203,7 @@ void AreaPropertyPanelBase::Update() OSL_ENSURE(false, "Non supported FillType (!)"); break; } + mpSidebarController->NotifyResize(); } } diff --git a/svx/uiconfig/ui/sidebararea.ui b/svx/uiconfig/ui/sidebararea.ui index 8d03ca35def2..efd1bcba568b 100644 --- a/svx/uiconfig/ui/sidebararea.ui +++ b/svx/uiconfig/ui/sidebararea.ui @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.16.1 --> <interface> + <!-- interface-requires LibreOffice 1.0 --> <requires lib="gtk+" version="3.0"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="upper">100</property> <property name="step_increment">1</property> @@ -46,6 +46,8 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -118,6 +120,8 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -141,13 +145,15 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> <object class="GtkToolbar" id="selectgradient"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">end</property> + <property name="halign">start</property> <child> <object class="GtkMenuToolButton" id="gradient"> <property name="visible">True</property> @@ -167,7 +173,71 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="svxlo-ColorLB" id="fillgrad2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="has_tooltip">True</property> + <property name="tooltip_markup" translatable="yes">Fill gradient to.</property> + <property name="tooltip_text" translatable="yes">Fill gradient to.</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="gradangle:0degrees"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_markup" translatable="yes">Select the gradient angle.</property> + <property name="tooltip_text" translatable="yes">Select the gradient angle.</property> + <property name="adjustment">adjustment2</property> + <child internal-child="accessible"> + <object class="AtkObject" id="gradangle:0degrees-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes">Gradient angle</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="gradientstyle"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="tooltip_markup" translatable="yes">Select the gradient style.</property> + <property name="tooltip_text" translatable="yes">Select the gradient style.</property> + <items> + <item translatable="yes">Linear</item> + <item translatable="yes">Axial</item> + <item translatable="yes">Radial</item> + <item translatable="yes">Ellipsoid</item> + <item translatable="yes">Quadratic</item> + <item translatable="yes">Square</item> + </items> + <child internal-child="accessible"> + <object class="AtkObject" id="gradientstyle-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes">Gradient Type</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -187,9 +257,6 @@ <item translatable="yes">Quadratic</item> <item translatable="yes">Square</item> </items> - <accessibility> - <relation type="labelled-by" target="transparencylabel"/> - </accessibility> <child internal-child="accessible"> <object class="AtkObject" id="transtype-atkobject"> <property name="AtkObject::accessible-name" translatable="yes">Transparency Type</property> @@ -198,7 +265,9 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -214,63 +283,46 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="svxlo-ColorLB" id="fillgrad2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="has_tooltip">True</property> - <property name="tooltip_markup" translatable="yes">Fill gradient to.</property> - <property name="tooltip_text" translatable="yes">Fill gradient to.</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkSpinButton" id="gradangle:0degrees"> + <object class="GtkButton" id="bmpimport"> + <property name="label" translatable="yes">_Import</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="tooltip_markup" translatable="yes">Select the gradient angle.</property> - <property name="tooltip_text" translatable="yes">Select the gradient angle.</property> - <property name="adjustment">adjustment2</property> - <child internal-child="accessible"> - <object class="AtkObject" id="gradangle:0degrees-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes">Gradient angle</property> - </object> - </child> + <property name="receives_default">True</property> + <property name="use_underline">True</property> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkComboBoxText" id="gradientstyle"> - <property name="visible">True</property> + <object class="svxlo-SvxFillAttrBox" id="fillbitmap"> <property name="can_focus">False</property> - <property name="tooltip_markup" translatable="yes">Select the gradient style.</property> - <property name="tooltip_text" translatable="yes">Select the gradient style.</property> - <items> - <item translatable="yes">Linear</item> - <item translatable="yes">Axial</item> - <item translatable="yes">Radial</item> - <item translatable="yes">Ellipsoid</item> - <item translatable="yes">Quadratic</item> - <item translatable="yes">Square</item> - </items> + <property name="has_tooltip">True</property> + <property name="tooltip_markup" translatable="yes">Select the effect to apply.</property> + <property name="tooltip_text" translatable="yes">Select the effect to apply.</property> + <accessibility> + <relation type="labelled-by" target="filllabel"/> + </accessibility> <child internal-child="accessible"> - <object class="AtkObject" id="gradientstyle-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes">Gradient Type</property> + <object class="AtkObject" id="fillbitmap-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes">Hatching/Bitmap</property> </object> </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -302,6 +354,7 @@ <property name="left_attach">0</property> <property name="top_attach">0</property> <property name="width">3</property> + <property name="height">1</property> </packing> </child> <child> @@ -326,6 +379,8 @@ <packing> <property name="left_attach">3</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> </object> @@ -339,6 +394,8 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> </object> |