[Libreoffice-commits] core.git: cui/source cui/uiconfig

Rishabh Kumar kris.kr296 at gmail.com
Tue Jul 19 18:33:13 UTC 2016


 cui/source/inc/cuitabarea.hxx   |    2 
 cui/source/tabpages/tphatch.cxx |   85 ++++++++++++++++++++++++++++------------
 cui/uiconfig/ui/hatchpage.ui    |    8 ++-
 3 files changed, 67 insertions(+), 28 deletions(-)

New commits:
commit ea96d97020322052a8d65e6e9bf521682819eb8e
Author: Rishabh Kumar <kris.kr296 at gmail.com>
Date:   Sun Jul 17 02:20:13 2016 +0530

    tdf#100907: Cannot set white background for hatching
    
    Change-Id: Id10cb4d90a19717b44d02064eb69981c69a421de
    Reviewed-on: https://gerrit.libreoffice.org/27258
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 2fa662d..835efd5 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -479,6 +479,7 @@ private:
     VclPtr<Slider>             m_pSliderAngle;
     VclPtr<ListBox>            m_pLbLineType;
     VclPtr<ColorLB>            m_pLbLineColor;
+    VclPtr<CheckBox>           m_pCbBackgroundColor;
     VclPtr<ColorLB>            m_pLbBackgroundColor;
     VclPtr<SvxPresetListBox>   m_pHatchLB;
     VclPtr<SvxXRectPreview>    m_pCtlPreview;
@@ -508,6 +509,7 @@ private:
     void ChangeHatchHdl_Impl();
     DECL_LINK_TYPED( ModifiedEditHdl_Impl, Edit&, void );
     DECL_LINK_TYPED( ModifiedListBoxHdl_Impl, ListBox&, void );
+    DECL_LINK_TYPED( ToggleHatchBackgroundColor_Impl, CheckBox&, void );
     DECL_LINK_TYPED( ModifiedBackgroundHdl_Impl, ListBox&, void );
     DECL_LINK_TYPED( ModifiedSliderHdl_Impl, Slider*, void );
     void ModifiedHdl_Impl(void*);
diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx
index 81bb046..b8a8dd9 100644
--- a/cui/source/tabpages/tphatch.cxx
+++ b/cui/source/tabpages/tphatch.cxx
@@ -73,6 +73,7 @@ SvxHatchTabPage::SvxHatchTabPage
     get(m_pSliderAngle, "angleslider");
     get(m_pLbLineType, "linetypelb");
     get(m_pLbLineColor, "linecolorlb");
+    get(m_pCbBackgroundColor, "backgroundcolor");
     get(m_pLbBackgroundColor, "backgroundcolorlb");
     get(m_pHatchLB , "hatchpresetlist");
     Size aSize = getDrawListBoxOptimalSize(this);
@@ -119,6 +120,7 @@ SvxHatchTabPage::SvxHatchTabPage
     m_pSliderAngle->SetSlideHdl( LINK( this, SvxHatchTabPage, ModifiedSliderHdl_Impl ) );
     m_pLbLineType->SetSelectHdl( aLink2 );
     m_pLbLineColor->SetSelectHdl( aLink2 );
+    m_pCbBackgroundColor->SetToggleHdl( LINK( this, SvxHatchTabPage, ToggleHatchBackgroundColor_Impl ) );
     m_pLbBackgroundColor->SetSelectHdl( LINK( this, SvxHatchTabPage, ModifiedBackgroundHdl_Impl ) );
 
     m_pBtnAdd->SetClickHdl( LINK( this, SvxHatchTabPage, ClickAddHdl_Impl ) );
@@ -221,19 +223,28 @@ void SvxHatchTabPage::ActivatePage( const SfxItemSet& rSet )
     }
 
     XFillBackgroundItem aBckItem( static_cast<const XFillBackgroundItem&>(rSet.Get(XATTR_FILLBACKGROUND)));
-    XFillColorItem aColorItem( static_cast<const XFillColorItem&>(rSet.Get(XATTR_FILLCOLOR)) );
-    Color aColor(COL_WHITE);
+    m_rXFSet.Put( aBckItem );
+
     if(aBckItem.GetValue())
-        aColor = aColorItem.GetColorValue();
-    m_pLbBackgroundColor->SelectEntry(aColor);
-    if( m_pLbBackgroundColor->GetSelectEntryCount() == 0 )
     {
-        m_pLbBackgroundColor->InsertEntry( aColor , OUString() );
-        m_pLbBackgroundColor->SelectEntry( aColor );
-    }
+        m_pCbBackgroundColor->SetState(TRISTATE_TRUE);
+        XFillColorItem aColorItem( static_cast<const XFillColorItem&>(rSet.Get(XATTR_FILLCOLOR)) );
+        Color aColor(aColorItem.GetColorValue());
+        m_pLbBackgroundColor->Enable();
+        m_pLbBackgroundColor->SelectEntry(aColor);
 
-    m_rXFSet.Put( aBckItem );
-    m_rXFSet.Put( aColorItem );
+        if( m_pLbBackgroundColor->GetSelectEntryCount() == 0 )
+        {
+            m_pLbBackgroundColor->InsertEntry( aColor , OUString() );
+            m_pLbBackgroundColor->SelectEntry( aColor );
+        }
+        m_rXFSet.Put( aColorItem );
+    }
+    else
+    {
+        m_pCbBackgroundColor->SetState(TRISTATE_FALSE);
+        m_pLbBackgroundColor->Disable();
+    }
 
     m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
     m_pCtlPreview->Invalidate();
@@ -344,12 +355,10 @@ bool SvxHatchTabPage::FillItemSet( SfxItemSet* rSet )
             rSet->Put( XFillStyleItem( drawing::FillStyle_HATCH ) );
             rSet->Put( XFillHatchItem( aString, *pXHatch ) );
 
-            sal_uInt32 nPosBckColor = m_pLbBackgroundColor->GetSelectEntryPos();
-            XFillBackgroundItem aItem( m_pLbBackgroundColor->GetSelectEntryColor() != COL_WHITE );
-            aItem.SetWhich( XATTR_FILLBACKGROUND );
-            rSet->Put( aItem );
-            if(aItem.GetValue())
+            rSet->Put( XFillBackgroundItem( m_pCbBackgroundColor->IsChecked() ) );
+            if(m_pCbBackgroundColor->IsChecked())
             {
+                sal_uInt32 nPosBckColor = m_pLbBackgroundColor->GetSelectEntryPos();
                 OUString aBckColorString;
                 if( nPosBckColor != LISTBOX_ENTRY_NOTFOUND )
                     aBckColorString = m_pLbBackgroundColor->GetSelectEntry();
@@ -367,8 +376,17 @@ void SvxHatchTabPage::Reset( const SfxItemSet* rSet )
 {
     ChangeHatchHdl_Impl();
 
-    m_rXFSet.Put( static_cast<const XFillColorItem&>(     rSet->Get(XATTR_FILLCOLOR)) );
-    m_rXFSet.Put( static_cast<const XFillBackgroundItem&>(rSet->Get(XATTR_FILLBACKGROUND)) );
+    XFillBackgroundItem aBckItem( static_cast<const XFillBackgroundItem&>(rSet->Get(XATTR_FILLBACKGROUND)) );
+    if(aBckItem.GetValue())
+        m_pCbBackgroundColor->SetState(TRISTATE_TRUE);
+    else
+        m_pCbBackgroundColor->SetState(TRISTATE_FALSE);
+    m_rXFSet.Put( aBckItem );
+
+    XFillColorItem aColItem( static_cast<const XFillColorItem&>(rSet->Get(XATTR_FILLCOLOR)) );
+    m_pLbBackgroundColor->SelectEntry(aColItem.GetColorValue());
+    m_rXFSet.Put( aColItem );
+
     m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
     m_pCtlPreview->Invalidate();
 }
@@ -385,14 +403,37 @@ IMPL_LINK_TYPED( SvxHatchTabPage, ModifiedListBoxHdl_Impl, ListBox&, rListBox, v
 {
     ModifiedHdl_Impl(&rListBox);
 }
-IMPL_LINK_TYPED( SvxHatchTabPage, ModifiedBackgroundHdl_Impl, ListBox&, rListBox, void )
+
+IMPL_LINK_NOARG_TYPED( SvxHatchTabPage, ToggleHatchBackgroundColor_Impl, CheckBox&, void )
 {
-    ModifiedHdl_Impl(&rListBox);
+    if(m_pCbBackgroundColor->IsChecked())
+        m_pLbBackgroundColor->Enable();
+    else
+        m_pLbBackgroundColor->Disable();
+    m_rXFSet.Put( XFillBackgroundItem( m_pCbBackgroundColor->IsChecked() ) );
+    ModifiedBackgroundHdl_Impl(*m_pLbBackgroundColor);
 }
+
+IMPL_LINK_NOARG_TYPED( SvxHatchTabPage, ModifiedBackgroundHdl_Impl, ListBox&, void )
+{
+    Color aColor(COL_TRANSPARENT);
+    if(m_pCbBackgroundColor->IsChecked())
+    {
+        aColor = m_pLbBackgroundColor->GetSelectEntryColor();
+        m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
+        m_pCtlPreview->Invalidate();
+    }
+    m_rXFSet.Put(XFillColorItem( OUString(), m_pLbBackgroundColor->GetSelectEntryColor() ));
+
+    m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
+    m_pCtlPreview->Invalidate();
+}
+
 IMPL_LINK_TYPED( SvxHatchTabPage, ModifiedEditHdl_Impl, Edit&, rEdit, void )
 {
     ModifiedHdl_Impl(&rEdit);
 }
+
 IMPL_LINK_TYPED( SvxHatchTabPage, ModifiedSliderHdl_Impl, Slider*, rSlider, void )
 {
     ModifiedHdl_Impl(rSlider);
@@ -412,13 +453,7 @@ void SvxHatchTabPage::ModifiedHdl_Impl( void* p )
 
     m_rXFSet.Put( XFillHatchItem( OUString(), aXHatch ) );
 
-    XFillBackgroundItem aItem( m_pLbBackgroundColor->GetSelectEntryColor() != COL_WHITE );
-    aItem.SetWhich( XATTR_FILLBACKGROUND );
-    m_rXFSet.Put( aItem );
-    if(aItem.GetValue())
-        m_rXFSet.Put( XFillColorItem( OUString(), m_pLbBackgroundColor->GetSelectEntryColor() ) );
     m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-
     m_pCtlPreview->Invalidate();
 }
 
diff --git a/cui/uiconfig/ui/hatchpage.ui b/cui/uiconfig/ui/hatchpage.ui
index cd1dc25..9552a9e 100644
--- a/cui/uiconfig/ui/hatchpage.ui
+++ b/cui/uiconfig/ui/hatchpage.ui
@@ -284,11 +284,13 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="backgroundcolorft">
+                      <object class="GtkCheckButton" id="backgroundcolor">
+                        <property name="label" translatable="yes">Background Color</property>
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
                         <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Background color:</property>
+                        <property name="draw_indicator">True</property>
                       </object>
                       <packing>
                         <property name="expand">False</property>


More information about the Libreoffice-commits mailing list