summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-02-07 18:25:39 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-09 10:11:34 +0000
commit8ef53812f161758826f9a4396f7d6416b29c5f97 (patch)
treef01eb42a873cb485bc434ff0cf1419c1a01a2368
parent63756b6bd3bc1c755b7a703fdbcc164fbff6acc2 (diff)
related: fdo#74230: Area tab page: prevent default gradient/hatch/bitmap
The Area dialog for shapes unfortunately makes it possible to set gradients/hatching/bitmap that uses the default items in the SfxItemPool. These items however cannot be stored to ODF files, since these are represented as elements, not as attributes on a style:default-style; what we get for defaults is a somewhat silly draw:fill="hatch" without an draw:fill-hatch-name. So prevent the dialog from creating them by forcing a selection of an entry in the list. Change-Id: I67cc6dbbf7b491f06d094d4de1e9c3ffe79b01f5 (cherry picked from commit 38d0047da7f964c862360b48d88cc869ad376b6b) Reviewed-on: https://gerrit.libreoffice.org/7930 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--cui/source/tabpages/tparea.cxx111
1 files changed, 64 insertions, 47 deletions
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index 462b410c57a6..773864aec144 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -1405,12 +1405,69 @@ sal_Bool SvxAreaTabPage::FillItemSet( SfxItemSet& rAttrs )
void SvxAreaTabPage::Reset( const SfxItemSet& rAttrs )
{
+ bool isMissingHatching(false);
+ bool isMissingGradient(false);
+ bool isMissingBitmap(false);
XFillStyle eXFS;
if( rAttrs.GetItemState( XATTR_FILLSTYLE ) != SFX_ITEM_DONTCARE )
{
eXFS = (XFillStyle) ( ( ( const XFillStyleItem& ) rAttrs.
Get( GetWhich( XATTR_FILLSTYLE ) ) ).GetValue() );
m_pTypeLB->SelectEntryPos( sal::static_int_cast< sal_uInt16 >( eXFS ) );
+
+ if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLCOLOR))
+ {
+ XFillColorItem const& rColorItem(static_cast<const XFillColorItem&>(
+ rAttrs.Get(XATTR_FILLCOLOR)) );
+ m_pLbColor->SelectEntry( rColorItem.GetColorValue() );
+ m_pLbHatchBckgrdColor->SelectEntry( rColorItem.GetColorValue() );
+ }
+
+ if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLGRADIENT))
+ {
+ XFillGradientItem const& rGradientItem(
+ static_cast<const XFillGradientItem&>(
+ rAttrs.Get(XATTR_FILLGRADIENT)) );
+ OUString const aString( rGradientItem.GetName() );
+ XGradient const aGradient( rGradientItem.GetGradientValue() );
+
+ m_pLbGradient->SelectEntryByList(pGradientList, aString, aGradient);
+ }
+ if (!m_pLbGradient->GetSelectEntryCount())
+ { // avoid relying on pool default - cannot export that
+ m_pLbGradient->SelectEntryPos(0); // anything better than nothing
+ isMissingGradient = true;
+ }
+
+ if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLHATCH))
+ {
+ m_pLbHatching->SelectEntry( static_cast<const XFillHatchItem&>(
+ rAttrs.Get(XATTR_FILLHATCH)).GetName() );
+ }
+ if (!m_pLbHatching->GetSelectEntryCount())
+ { // avoid relying on pool default - cannot export that
+ m_pLbHatching->SelectEntryPos(0); // anything better than nothing
+ isMissingHatching = true;
+ }
+ if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLBACKGROUND))
+ {
+ m_pCbxHatchBckgrd->Check( static_cast<const XFillBackgroundItem&>(
+ rAttrs.Get(XATTR_FILLBACKGROUND)).GetValue() );
+ }
+
+ if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLBITMAP))
+ {
+ XFillBitmapItem const& rBitmapItem(
+ static_cast<const XFillBitmapItem&>(
+ rAttrs.Get(XATTR_FILLBITMAP)));
+ m_pLbBitmap->SelectEntry(rBitmapItem.GetName());
+ }
+ if (!m_pLbBitmap->GetSelectEntryCount())
+ { // avoid relying on pool default - cannot export that
+ m_pLbBitmap->SelectEntryPos(0); // anything better than nothing
+ isMissingBitmap = true;
+ }
+
switch( eXFS )
{
case XFILL_NONE:
@@ -1418,69 +1475,26 @@ void SvxAreaTabPage::Reset( const SfxItemSet& rAttrs )
break;
case XFILL_SOLID:
- if( SFX_ITEM_DONTCARE != rAttrs.GetItemState( XATTR_FILLCOLOR ) )
- {
- XFillColorItem aColorItem( ( const XFillColorItem& )
- rAttrs.Get( XATTR_FILLCOLOR ) );
-
- m_pLbColor->SelectEntry( aColorItem.GetColorValue() );
- m_pLbHatchBckgrdColor->SelectEntry( aColorItem.GetColorValue() );
- }
ClickColorHdl_Impl();
-
break;
case XFILL_GRADIENT:
- if( SFX_ITEM_DONTCARE != rAttrs.GetItemState( XATTR_FILLGRADIENT ) )
- {
- XFillGradientItem aGradientItem( ( ( const XFillGradientItem& )
- rAttrs.Get( XATTR_FILLGRADIENT ) ) );
- OUString aString( aGradientItem.GetName() );
- XGradient aGradient( aGradientItem.GetGradientValue() );
-
- m_pLbGradient->SelectEntryByList( pGradientList, aString, aGradient );
- }
ClickGradientHdl_Impl();
break;
case XFILL_HATCH:
- if( SFX_ITEM_DONTCARE != rAttrs.GetItemState( XATTR_FILLHATCH ) )
- {
- m_pLbHatching->SelectEntry( ( ( const XFillHatchItem& )
- rAttrs.Get( XATTR_FILLHATCH ) ).GetName() );
- }
ClickHatchingHdl_Impl();
-
- if ( SFX_ITEM_DONTCARE != rAttrs.GetItemState ( XATTR_FILLBACKGROUND ) )
- {
- m_pCbxHatchBckgrd->Check ( ( ( const XFillBackgroundItem& ) rAttrs.Get ( XATTR_FILLBACKGROUND ) ).GetValue() );
- }
ToggleHatchBckgrdColorHdl_Impl( this );
- if( SFX_ITEM_DONTCARE != rAttrs.GetItemState( XATTR_FILLCOLOR ) )
- {
- XFillColorItem aColorItem( ( const XFillColorItem& )
- rAttrs.Get( XATTR_FILLCOLOR ) );
-
- m_pLbColor->SelectEntry( aColorItem.GetColorValue() );
- m_pLbHatchBckgrdColor->SelectEntry( aColorItem.GetColorValue() );
- }
break;
case XFILL_BITMAP:
{
- if( SFX_ITEM_DONTCARE != rAttrs.GetItemState( XATTR_FILLBITMAP ) )
- {
- XFillBitmapItem aBitmapItem( ( const XFillBitmapItem& )
- rAttrs.Get( XATTR_FILLBITMAP ) );
-
- OUString aString( aBitmapItem.GetName() );
- m_pLbBitmap->SelectEntry( aString );
- }
ClickBitmapHdl_Impl();
}
break;
default:
+ assert(false);
break;
}
}
@@ -1687,10 +1701,13 @@ void SvxAreaTabPage::Reset( const SfxItemSet& rAttrs )
m_pTypeLB->SaveValue();
m_pLbColor->SaveValue();
- m_pLbGradient->SaveValue();
- m_pLbHatching->SaveValue();
+ if (!isMissingGradient)
+ m_pLbGradient->SaveValue();
+ if (!isMissingHatching)
+ m_pLbHatching->SaveValue();
m_pLbHatchBckgrdColor->SaveValue();
- m_pLbBitmap->SaveValue();
+ if (!isMissingBitmap)
+ m_pLbBitmap->SaveValue();
m_pTsbStepCount->SaveValue();
m_pNumFldStepCount->SaveValue();
m_pTsbTile->SaveValue();