[Libreoffice-commits] core.git: 2 commits - cui/source xmloff/source
Michael Stahl
mstahl at redhat.com
Fri Feb 7 10:01:08 PST 2014
cui/source/tabpages/tparea.cxx | 111 +++++++++++++++++++++++-----------------
xmloff/source/draw/sdpropls.cxx | 7 +-
2 files changed, 68 insertions(+), 50 deletions(-)
New commits:
commit 38d0047da7f964c862360b48d88cc869ad376b6b
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Feb 7 18:25:39 2014 +0100
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
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index 2b25f14..b0397f3 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();
commit 45d3577bc5726eee44f491fd30a7f11dc428431a
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Feb 7 16:25:06 2014 +0100
fdo#74230: ODF export: write stroke and fill color in graphic defaults
The pool defaults for svg:stroke-color and draw:fill-color were changed
and while previously (effective, manually overridden) defaults were
written into ODF files, this was lost with the change; restore that.
(regression from c0eb5e7772c848806db8ab461f77f9549c1d8b2b)
Change-Id: Ibcd863260976aa42116175c7f19cb33760af986f
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index b3bb720..9167dca 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -74,6 +74,7 @@ using namespace ::xmloff::token;
#define _MAP(name,prefix,token,type,context) { name, sizeof(name)-1, prefix, token, type, context, SvtSaveOptions::ODFVER_010, false }
#define _MAPV(name,prefix,token,type,context,version) { name, sizeof(name)-1, prefix, token, type, context, version, false }
#define GMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_GRAPHIC,context)
+#define GMAP_D(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_GRAPHIC|MID_FLAG_DEFAULT_ITEM_EXPORT,context)
#define GMAPV(name,prefix,token,type,context,version) _MAPV(name,prefix,token,type|XML_TYPE_PROP_GRAPHIC,context,version)
#define DPMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_DRAWING_PAGE,context)
#define TMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_TEXT,context)
@@ -93,7 +94,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
GMAP( "LineStyle", XML_NAMESPACE_DRAW, XML_STROKE, XML_SD_TYPE_STROKE, 0 ),
GMAP( "LineDashName", XML_NAMESPACE_DRAW, XML_STROKE_DASH, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT , CTF_DASHNAME ),
GMAP( "LineWidth", XML_NAMESPACE_SVG, XML_STROKE_WIDTH, XML_TYPE_MEASURE, 0 ),
- GMAP( "LineColor", XML_NAMESPACE_SVG, XML_STROKE_COLOR, XML_TYPE_COLOR, 0 ),
+ GMAP_D("LineColor", XML_NAMESPACE_SVG, XML_STROKE_COLOR, XML_TYPE_COLOR, 0),
GMAP( "LineStartName", XML_NAMESPACE_DRAW, XML_MARKER_START, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_LINESTARTNAME ),
GMAP( "LineStartWidth", XML_NAMESPACE_DRAW, XML_MARKER_START_WIDTH, XML_TYPE_MEASURE, 0 ),
GMAP( "LineStartCenter", XML_NAMESPACE_DRAW, XML_MARKER_START_CENTER, XML_TYPE_BOOL, 0 ),
@@ -106,8 +107,8 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
// fill attributes
GMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, 0 ),
- GMAP( "FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0 ),
- GMAP( "FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0 ),
+ GMAP_D("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0),
+ GMAP_D("FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0),
GMAP( "FillGradientName", XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLGRADIENTNAME ),
GMAP( "FillGradientStepCount", XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER16, 0 ),
GMAP( "FillHatchName", XML_NAMESPACE_DRAW, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLHATCHNAME ),
More information about the Libreoffice-commits
mailing list