summaryrefslogtreecommitdiff
path: root/oox/source/export/drawingml.cxx
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@novell.com>2010-11-01 14:13:53 +0200
committerTor Lillqvist <tml@hemulen.(none)>2010-11-13 12:24:04 +0200
commitba0ab700b4cebd88e07ebe0662f560b2b9dfb918 (patch)
tree32b71bb58d8b7f0aa7c6900963fb1562ee899a6c /oox/source/export/drawingml.cxx
parent89579fd0db5dcc728f756f94eb68de1b9df3efe1 (diff)
From hg changeset 2b3eef7bad494312ee9c8c13c1b1014b22ba0451 in ooxml11
ooxml11: merge with DEV300 m76 (I hope), plus intermediate commit of own changes
Diffstat (limited to 'oox/source/export/drawingml.cxx')
-rw-r--r--oox/source/export/drawingml.cxx130
1 files changed, 114 insertions, 16 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 240e31fb079d..a2e86b922bce 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -40,6 +40,8 @@
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
@@ -54,7 +56,10 @@
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/style/LineSpacingMode.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextField.hpp>
@@ -73,9 +78,12 @@
#include <editeng/svxenum.hxx>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::uno;
using ::com::sun::star::beans::PropertyState;
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::beans::XPropertySet;
@@ -84,6 +92,7 @@ using ::com::sun::star::container::XEnumeration;
using ::com::sun::star::container::XEnumerationAccess;
using ::com::sun::star::container::XIndexAccess;
using ::com::sun::star::io::XOutputStream;
+using ::com::sun::star::style::LineSpacing;
using ::com::sun::star::text::XText;
using ::com::sun::star::text::XTextContent;
using ::com::sun::star::text::XTextField;
@@ -108,6 +117,44 @@ namespace drawingml {
#define GET(variable, propName) \
if ( GETA(propName) ) \
mAny >>= variable;
+DBG(
+void lcl_dump_pset(Reference< XPropertySet > rXPropSet)
+{
+ Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo ();
+ Sequence< beans::Property > props = info->getProperties ();
+
+ for (int i=0; i < props.getLength (); i++) {
+ OString name = OUStringToOString( props [i].Name, RTL_TEXTENCODING_UTF8);
+ fprintf (stderr,"%30s = ", name.getStr() );
+
+ try {
+ Any value = rXPropSet->getPropertyValue( props [i].Name );
+
+ OUString strValue;
+ sal_Int32 intValue;
+ bool boolValue;
+ LineSpacing spacing;
+// RectanglePoint pointValue;
+
+ if( value >>= strValue )
+ fprintf (stderr,"\"%s\"\n", USS( strValue ) );
+ else if( value >>= intValue )
+ fprintf (stderr,"%d (hex: %x)\n", intValue, intValue);
+ else if( value >>= boolValue )
+ fprintf (stderr,"%d (bool)\n", boolValue);
+ else if( value >>= spacing ) {
+ fprintf (stderr, "mode: %d value: %d\n", spacing.Mode, spacing.Height);
+ }
+// else if( value >>= pointValue )
+// fprintf (stderr,"%d (RectanglePoint)\n", pointValue);
+ else
+ fprintf (stderr,"??? <unhandled type>\n");
+ } catch(Exception e) {
+ fprintf (stderr,"unable to get '%s' value\n", USS(props [i].Name));
+ }
+ }
+}
+);
// not thread safe
int DrawingML::mnImageCounter = 1;
@@ -523,15 +570,27 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic )
return sRelId;
}
-OUString DrawingML::WriteBlip( OUString& rURL )
+OUString DrawingML::WriteBlip( Reference< XPropertySet > rXPropSet, OUString& rURL )
{
OUString sRelId = WriteImage( rURL );
+ sal_Int16 nBright = 0;
+ sal_Int32 nContrast = 0;
+
+ GET( nBright, AdjustLuminance );
+ GET( nContrast, AdjustContrast );
+
+ mpFS->startElementNS( XML_a, XML_blip,
+ FSNS( XML_r, XML_embed), OUStringToOString( sRelId, RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSEND );
+ if( nBright || nContrast )
+ mpFS->singleElementNS( XML_a, XML_lum,
+ XML_bright, nBright ? I32S( nBright*1000 ) : NULL,
+ XML_contrast, nContrast ? I32S( nContrast*1000 ) : NULL,
+ FSEND );
- mpFS->singleElementNS( XML_a, XML_blip,
- FSNS( XML_r, XML_embed), OUStringToOString( sRelId, RTL_TEXTENCODING_UTF8 ).getStr(),
- FSEND );
+ mpFS->endElementNS( XML_a, XML_blip );
- return sRelId;
+ return sRelId;
}
void DrawingML::WriteBlipMode( Reference< XPropertySet > rXPropSet )
@@ -569,7 +628,7 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, String sURLP
mpFS->startElementNS( nXmlNamespace , XML_blipFill, FSEND );
- WriteBlip( aURL );
+ WriteBlip( rXPropSet, aURL );
if( sURLPropName == S( "FillBitmapURL" ) )
WriteBlipMode( rXPropSet );
@@ -753,8 +812,6 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, sal_Bool bIs
else
typeface = USS( usTypeface );
-
-
mpFS->singleElementNS( XML_a, XML_latin,
XML_typeface, typeface,
XML_pitchFamily, pitch,
@@ -918,7 +975,6 @@ void DrawingML::WriteRun( Reference< XTextRange > rRun )
else if( bSDot ) \
pAutoNumType = #x "Period";
-
inline static const char* GetAutoNumType( sal_Int16 nNumberingType, bool bSDot, bool bPBehind, bool bPBoth )
{
const char* pAutoNumType = NULL;
@@ -964,7 +1020,6 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
Sequence< PropertyValue > aPropertySequence;
rXIndexAccess->getByIndex( nLevel ) >>= aPropertySequence;
-
const PropertyValue* pPropValue = aPropertySequence.getArray();
sal_Int32 nPropertyCount = aPropertySequence.getLength();
@@ -1086,14 +1141,30 @@ const char* DrawingML::GetAlignment( sal_Int32 nAlignment )
return sAlignment;
}
+void DrawingML::WriteLinespacing( LineSpacing& rSpacing )
+{
+ if( rSpacing.Mode == LineSpacingMode::PROP )
+ mpFS->singleElementNS( XML_a, XML_spcPct,
+ XML_val, I32S( ((sal_Int32)rSpacing.Height)*1000 ),
+ FSEND );
+ else
+ mpFS->singleElementNS( XML_a, XML_spcPts,
+ XML_val, I32S( rSpacing.Height ),
+ FSEND );
+}
+
void DrawingML::WriteParagraphProperties( Reference< XTextContent > rParagraph )
{
Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY );
Reference< XPropertyState > rXPropState( rParagraph, UNO_QUERY );
+ PropertyState eState;
if( !rXPropSet.is() || !rXPropState.is() )
return;
+ //OSL_TRACE("write paragraph properties pset");
+ //DBG(lcl_dump_pset(rXPropSet));
+
sal_Int16 nLevel = -1;
GET( nLevel, NumberingLevel );
@@ -1104,15 +1175,27 @@ void DrawingML::WriteParagraphProperties( Reference< XTextContent > rParagraph )
sal_Int16 nAlignment( style::ParagraphAdjust_LEFT );
GET( nAlignment, ParaAdjust );
+ sal_Bool bHasLinespacing = sal_False;
+ LineSpacing aLineSpacing;
+ if( GETAD( ParaLineSpacing ) )
+ bHasLinespacing = ( mAny >>= aLineSpacing );
+
if( nLevel != -1
- || nLeftMargin > 0
- || nAlignment != style::ParagraphAdjust_LEFT ) {
+ || nLeftMargin > 0
+ || nAlignment != style::ParagraphAdjust_LEFT
+ || bHasLinespacing ) {
mpFS->startElementNS( XML_a, XML_pPr,
XML_lvl, nLevel > 0 ? I32S( nLevel ) : NULL,
XML_marL, nLeftMargin > 0 ? IS( nLeftMargin ) : NULL,
XML_algn, GetAlignment( nAlignment ),
FSEND );
+ if( bHasLinespacing ) {
+ mpFS->startElementNS( XML_a, XML_lnSpc, FSEND );
+ WriteLinespacing( aLineSpacing );
+ mpFS->endElementNS( XML_a, XML_lnSpc );
+ }
+
WriteParagraphNumbering( rXPropSet, nLevel );
mpFS->endElementNS( XML_a, XML_pPr );
@@ -1185,11 +1268,24 @@ void DrawingML::WriteText( Reference< XShape > rXShape )
;
}
+ const char* sWritingMode = NULL;
+ sal_Bool bVertical = sal_False;
+ if( GETA( TextWritingMode ) ) {
+ WritingMode eMode;
+
+ if( ( mAny >>= eMode ) && eMode == WritingMode_TB_RL ) {
+ sWritingMode = "vert";
+ bVertical = sal_True;
+ }
+ }
+
TextHorizontalAdjust eHorizontalAlignment( TextHorizontalAdjust_CENTER );
bool bHorizontalCenter = false;
GET( eHorizontalAlignment, TextHorizontalAdjust );
if( eHorizontalAlignment == TextHorizontalAdjust_CENTER )
bHorizontalCenter = true;
+ else if( bVertical && eHorizontalAlignment == TextHorizontalAdjust_LEFT )
+ sVerticalAlignment = "b";
sal_Bool bHasWrap = FALSE;
sal_Bool bWrap = FALSE;
@@ -1207,6 +1303,7 @@ void DrawingML::WriteText( Reference< XShape > rXShape )
XML_bIns, (nBottom != DEFTBINS) ? IS( MM100toEMU( nBottom ) ) : NULL,
XML_anchor, sVerticalAlignment,
XML_anchorCtr, bHorizontalCenter ? "1" : NULL,
+ XML_vert, sWritingMode,
FSEND );
Reference< XEnumerationAccess > access( xXText, UNO_QUERY );
@@ -1244,7 +1341,10 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo
mpFS->startElementNS( XML_a, XML_avLst, FSEND );
Sequence< drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
- if ( rProp.Value >>= aAdjustmentSeq ) {
+ if ( ( rProp.Value >>= aAdjustmentSeq )
+ && eShapeType != mso_sptActionButtonForwardNext // we have adjustments values for these type of shape, but MSO doesn't like them
+ && eShapeType != mso_sptActionButtonBackPrevious // so they are now disabled
+ ) {
DBG(printf("adj seq len: %d\n", int( aAdjustmentSeq.getLength() )));
if ( bPredefinedHandlesUsed )
EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
@@ -1481,8 +1581,6 @@ void DrawingML::WriteFill( Reference< XPropertySet > xPropSet )
return;
}
-
-
}
}