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

Miklos Vajna vmiklos at suse.cz
Thu Feb 14 03:41:55 PST 2013


 cui/source/tabpages/backgrnd.cxx  |   64 +++++++++++++++++++++++++++++---------
 cui/uiconfig/ui/backgroundpage.ui |   30 ++++++++++++++---
 2 files changed, 73 insertions(+), 21 deletions(-)

New commits:
commit 8a1f3b582d7e8ce46e310bf3e0fdbf3ee26c1712
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Feb 14 12:13:16 2013 +0100

    SvxBackgroundTabPage: use XFillStyle enum
    
    Change-Id: I8fb8765ed6ee2f879a170f4f9c51ee05b695304a

diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 8309d1b..9c139e3 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -117,6 +117,23 @@ static void lcl_SetTransparency(SvxBrushItem& rBrush, long nTransparency)
     aTransparency <<= (sal_Int8)nTransparency;
     rBrush.PutValue(aTransparency, MID_GRAPHIC_TRANSPARENCY);
 }
+
+/// Returns the fill style of the currently selected entry.
+static XFillStyle lcl_getFillStyle(ListBox* pLbSelect)
+{
+    return (XFillStyle)(sal_uLong)pLbSelect->GetEntryData(pLbSelect->GetSelectEntryPos());
+}
+
+// Selects the entry matching the specified fill style.
+static void lcl_setFillStyle(ListBox* pLbSelect, XFillStyle eStyle)
+{
+    for (int i = 0; i < pLbSelect->GetEntryCount(); ++i)
+        if ((XFillStyle)(sal_uLong)pLbSelect->GetEntryData(i) == eStyle)
+        {
+            pLbSelect->SelectEntryPos(i);
+            return;
+        }
+}
 //-------------------------------------------------------------------------
 
 sal_uInt16 GetItemId_Impl( ValueSet& rValueSet, const Color& rCol )
@@ -537,7 +554,7 @@ void SvxBackgroundTabPage::Reset( const SfxItemSet& rSet )
     {
         m_pSelectTxt->Hide();
         m_pLbSelect->Hide();
-        m_pLbSelect->SelectEntryPos( 0 );
+        lcl_setFillStyle(m_pLbSelect, XFILL_SOLID);
         ShowColorUI_Impl();
 
         const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_BRUSH );
@@ -664,7 +681,7 @@ void SvxBackgroundTabPage::ResetFromWallpaperItem( const SfxItemSet& rSet )
     }
     else
     {
-        m_pLbSelect->SelectEntryPos( 0 );
+        lcl_setFillStyle(m_pLbSelect, XFILL_SOLID);
         ShowColorUI_Impl();
 
         const SfxPoolItem* pOld = GetOldItem( rSet, SID_VIEW_FLD_PIC );
@@ -758,8 +775,8 @@ sal_Bool SvxBackgroundTabPage::FillItemSet( SfxItemSet& rCoreSet )
     {
         const SvxBrushItem& rOldItem    = (const SvxBrushItem&)*pOld;
         SvxGraphicPosition  eOldPos     = rOldItem.GetGraphicPos();
-        const sal_Bool          bIsBrush    = ( 0 == m_pLbSelect->GetSelectEntryPos() );
-        const bool bIsGradient = ( 2 == m_pLbSelect->GetSelectEntryPos() );
+        const sal_Bool          bIsBrush    = ( XFILL_SOLID == lcl_getFillStyle(m_pLbSelect) );
+        const bool bIsGradient = ( XFILL_GRADIENT == lcl_getFillStyle(m_pLbSelect) );
 
         // transparency has to be set if enabled, the color not already set to "No fill" and
         if( bColTransparency &&
@@ -990,7 +1007,7 @@ sal_Bool SvxBackgroundTabPage::FillItemSetWithWallpaperItem( SfxItemSet& rCoreSe
 
     SvxBrushItem        rOldItem( (const CntWallpaperItem&)*pOld, nWhich );
     SvxGraphicPosition  eOldPos     = rOldItem.GetGraphicPos();
-    const sal_Bool          bIsBrush    = ( 0 == m_pLbSelect->GetSelectEntryPos() );
+    const sal_Bool          bIsBrush    = ( XFILL_SOLID == lcl_getFillStyle(m_pLbSelect) );
     sal_Bool                bModified = sal_False;
 
     if (   ( (GPOS_NONE == eOldPos) && bIsBrush  )
@@ -1395,12 +1412,12 @@ IMPL_LINK_NOARG(SvxBackgroundTabPage, BackgroundColorHdl_Impl)
 
 IMPL_LINK_NOARG(SvxBackgroundTabPage, SelectHdl_Impl)
 {
-    if ( 0 == m_pLbSelect->GetSelectEntryPos() )
+    if ( XFILL_SOLID == lcl_getFillStyle(m_pLbSelect) )
     {
         ShowColorUI_Impl();
         m_pParaLBox->Enable(); // drawing background can't be a bitmap
     }
-    else if ( 1 == m_pLbSelect->GetSelectEntryPos() )
+    else if ( XFILL_BITMAP == lcl_getFillStyle(m_pLbSelect) )
     {
         ShowBitmapUI_Impl();
         m_pParaLBox->Enable(sal_False); // drawing background can't be a bitmap
@@ -1649,7 +1666,7 @@ IMPL_LINK( SvxBackgroundTabPage, TblDestinationHdl_Impl, ListBox*, pBox )
         pTableBck_Impl->nActPos = nSelPos;
         if(!*pActItem)
             *pActItem = new SvxBrushItem(nWhich);
-        if(0 == m_pLbSelect->GetSelectEntryPos())  // brush selected
+        if(XFILL_SOLID == lcl_getFillStyle(m_pLbSelect))  // brush selected
         {
             **pActItem = SvxBrushItem( aBgdColor, nWhich );
         }
@@ -1719,7 +1736,7 @@ IMPL_LINK( SvxBackgroundTabPage, ParaDestinationHdl_Impl, ListBox*, pBox )
             break;
         }
         pParaBck_Impl->nActPos = nSelPos;
-        if(0 == m_pLbSelect->GetSelectEntryPos())  // brush selected
+        if(XFILL_SOLID == lcl_getFillStyle(m_pLbSelect))  // brush selected
         {
             sal_uInt16 nWhich = (*pActItem)->Which();
             **pActItem = SvxBrushItem( aBgdColor, nWhich );
@@ -1786,7 +1803,7 @@ void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr,
         // We don't have a graphic, do we have gradient fill style?
         if (!m_rXFillSet.HasItem(XATTR_FILLSTYLE) || ((const XFillStyleItem&)m_rXFillSet.Get(XATTR_FILLSTYLE)).GetValue() != XFILL_GRADIENT)
         {
-            m_pLbSelect->SelectEntryPos( 0 );
+            lcl_setFillStyle(m_pLbSelect, XFILL_SOLID);
             ShowColorUI_Impl();
             Color aTrColor( COL_TRANSPARENT );
             aBgdColor = rColor;
@@ -1808,7 +1825,7 @@ void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr,
         else
         {
             // Gradient fill style, then initialize preview with data from Writer.
-            m_pLbSelect->SelectEntryPos( 2 );
+            lcl_setFillStyle(m_pLbSelect, XFILL_GRADIENT);
             ShowGradientUI_Impl();
             m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
             m_pCtlPreview->Invalidate();
@@ -1831,7 +1848,7 @@ void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr,
         const String*   pStrLink   = rBgdAttr.GetGraphicLink();
         const String*   pStrFilter = rBgdAttr.GetGraphicFilter();
 
-        m_pLbSelect->SelectEntryPos( 1 );
+        lcl_setFillStyle(m_pLbSelect, XFILL_BITMAP);
         ShowBitmapUI_Impl();
 
         if ( pStrLink )
@@ -1945,7 +1962,12 @@ void SvxBackgroundTabPage::PageCreated (SfxAllItemSet aSet)
     }
     else
         // Otherwise hide the gradient UI.
-        m_pLbSelect->RemoveEntry(2);
+        for (int i = 0; i < m_pLbSelect->GetEntryCount(); ++i)
+            if ((XFillStyle)(sal_uLong)m_pLbSelect->GetEntryData(i) == XFILL_GRADIENT)
+            {
+                m_pLbSelect->RemoveEntry(i);
+                break;
+            }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/uiconfig/ui/backgroundpage.ui b/cui/uiconfig/ui/backgroundpage.ui
index d6395a2..6458537 100644
--- a/cui/uiconfig/ui/backgroundpage.ui
+++ b/cui/uiconfig/ui/backgroundpage.ui
@@ -33,16 +33,12 @@
           </packing>
         </child>
         <child>
-          <object class="GtkComboBoxText" id="selectlb">
+          <object class="GtkComboBox" id="selectlb">
             <property name="can_focus">False</property>
             <property name="no_show_all">True</property>
+            <property name="model">liststore1</property>
             <property name="entry_text_column">0</property>
             <property name="id_column">1</property>
-            <items>
-              <item translatable="yes">Color</item>
-              <item translatable="yes">Graphic</item>
-              <item translatable="yes">Gradient</item>
-            </items>
           </object>
           <packing>
             <property name="left_attach">1</property>
@@ -697,4 +693,26 @@
       </packing>
     </child>
   </object>
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name gchararray1 -->
+      <column type="gchararray"/>
+      <!-- column-name gint1 -->
+      <column type="gint"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Color</col>
+        <col id="1">1</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Gradient</col>
+        <col id="1">2</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Graphic</col>
+        <col id="1">4</col>
+      </row>
+    </data>
+  </object>
 </interface>
commit 1417d691a6ea9024ca392d725b331037a175f723
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Feb 13 15:43:22 2013 +0100

    SvxBackgroundTabPage: select matching gradient entry on load, if possible
    
    Change-Id: Ie654fc795a3f46f1ff26a1ff5adb7e8ce9091851

diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index d436bb1..8309d1b 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -1286,6 +1286,12 @@ void SvxBackgroundTabPage::ShowGradientUI_Impl()
             m_pLbGradients->SelectEntryPos(0);
             ModifyGradientHdl_Impl(this);
         }
+        else
+        {
+            // It has one, try to select the matching entry in the gradient list box.
+            const XFillGradientItem& rFillGradientItem = (const XFillGradientItem&)m_rXFillSet.Get(XATTR_FILLGRADIENT);
+            m_pLbGradients->SelectEntryByList(m_pGradientList, rFillGradientItem.GetName(), rFillGradientItem.GetGradientValue());
+        }
     }
 }
 
@@ -1483,7 +1489,7 @@ IMPL_LINK_NOARG(SvxBackgroundTabPage, ModifyGradientHdl_Impl)
     {
         XGradientEntry* pEntry = m_pGradientList->GetGradient(nPos);
         m_rXFillSet.Put( XFillStyleItem( XFILL_GRADIENT ) );
-        m_rXFillSet.Put( XFillGradientItem( String(), pEntry->GetGradient() ) );
+        m_rXFillSet.Put( XFillGradientItem( pEntry->GetName(), pEntry->GetGradient() ) );
     }
     m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
     m_pCtlPreview->Invalidate();
@@ -1935,7 +1941,7 @@ void SvxBackgroundTabPage::PageCreated (SfxAllItemSet aSet)
         const XFillStyleItem& rFillStyleItem = (const XFillStyleItem&)aSet.Get(SID_ATTR_FILL_STYLE);
         m_rXFillSet.Put(XFillStyleItem(rFillStyleItem.GetValue()));
         const XFillGradientItem& rFillGradientItem = (const XFillGradientItem&)aSet.Get(SID_ATTR_FILL_GRADIENT);
-        m_rXFillSet.Put(XFillGradientItem(rFillGradientItem.GetGradientValue()));
+        m_rXFillSet.Put(XFillGradientItem(rFillGradientItem.GetName(), rFillGradientItem.GetGradientValue()));
     }
     else
         // Otherwise hide the gradient UI.
commit ea7eef21707bb18ec5811f27c0584fe9421e30d8
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Feb 13 13:14:55 2013 +0100

    SvxBackgroundTabPage: fix non-gradient preview in gradient frame
    
    Change-Id: Ia7d64301a250bf51a6343f155144edced8e3bd09

diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 3553df8..d436bb1 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -1280,6 +1280,12 @@ void SvxBackgroundTabPage::ShowGradientUI_Impl()
         HideBitmapUI_Impl();
 
         m_pBackGroundGradientFrame->Show();
+        if (!m_rXFillSet.HasItem(XATTR_FILLSTYLE) || ((const XFillStyleItem&)m_rXFillSet.Get(XATTR_FILLSTYLE)).GetValue() != XFILL_GRADIENT)
+        {
+            // Frame has no gradient? Then select the first one, just to be able to show something in the preview control.
+            m_pLbGradients->SelectEntryPos(0);
+            ModifyGradientHdl_Impl(this);
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list