1ca5ec200SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3ca5ec200SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4ca5ec200SAndrew Rist * or more contributor license agreements. See the NOTICE file 5ca5ec200SAndrew Rist * distributed with this work for additional information 6ca5ec200SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7ca5ec200SAndrew Rist * to you under the Apache License, Version 2.0 (the 8ca5ec200SAndrew Rist * "License"); you may not use this file except in compliance 9ca5ec200SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11ca5ec200SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13ca5ec200SAndrew Rist * Unless required by applicable law or agreed to in writing, 14ca5ec200SAndrew Rist * software distributed under the License is distributed on an 15ca5ec200SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16ca5ec200SAndrew Rist * KIND, either express or implied. See the License for the 17ca5ec200SAndrew Rist * specific language governing permissions and limitations 18ca5ec200SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20ca5ec200SAndrew Rist *************************************************************/ 21ca5ec200SAndrew Rist 22ca5ec200SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx" 25cdf0e10cSrcweir #include "oox/export/drawingml.hxx" 26cdf0e10cSrcweir #include "oox/export/utils.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <cstdio> 29cdf0e10cSrcweir #include <com/sun/star/awt/CharSet.hpp> 30cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp> 31cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp> 33cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp> 34cdf0e10cSrcweir #include <com/sun/star/awt/Gradient.hpp> 35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp> 37cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp> 38cdf0e10cSrcweir #include <com/sun/star/drawing/BitmapMode.hpp> 39cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> 40cdf0e10cSrcweir #include <com/sun/star/drawing/LineDash.hpp> 41cdf0e10cSrcweir #include <com/sun/star/drawing/LineJoint.hpp> 42cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp> 43cdf0e10cSrcweir #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> 44cdf0e10cSrcweir #include <com/sun/star/drawing/TextVerticalAdjust.hpp> 45cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp> 46cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 47cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp> 48cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp> 49cdf0e10cSrcweir #include <com/sun/star/text/XTextContent.hpp> 50cdf0e10cSrcweir #include <com/sun/star/text/XTextField.hpp> 51cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp> 52cdf0e10cSrcweir #include <tools/stream.hxx> 53cdf0e10cSrcweir #include <tools/string.hxx> 54cdf0e10cSrcweir #include <vcl/cvtgrf.hxx> 55cdf0e10cSrcweir #include <unotools/fontcvt.hxx> 56cdf0e10cSrcweir #include <vcl/graph.hxx> 57cdf0e10cSrcweir #include <svtools/grfmgr.hxx> 58cdf0e10cSrcweir #include <rtl/strbuf.hxx> 59cdf0e10cSrcweir #include <sfx2/app.hxx> 60cdf0e10cSrcweir #include <svl/languageoptions.hxx> 61cdf0e10cSrcweir #include <svx/escherex.hxx> 62cdf0e10cSrcweir #include <svx/svxenum.hxx> 63cdf0e10cSrcweir 64cdf0e10cSrcweir using namespace ::com::sun::star; 65cdf0e10cSrcweir using namespace ::com::sun::star::uno; 66cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 67cdf0e10cSrcweir using namespace ::com::sun::star::i18n; 68cdf0e10cSrcweir using ::com::sun::star::beans::PropertyState; 69cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue; 70cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 71cdf0e10cSrcweir using ::com::sun::star::beans::XPropertyState; 72cdf0e10cSrcweir using ::com::sun::star::container::XEnumeration; 73cdf0e10cSrcweir using ::com::sun::star::container::XEnumerationAccess; 74cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess; 75cdf0e10cSrcweir using ::com::sun::star::io::XOutputStream; 76cdf0e10cSrcweir using ::com::sun::star::text::XText; 77cdf0e10cSrcweir using ::com::sun::star::text::XTextContent; 78cdf0e10cSrcweir using ::com::sun::star::text::XTextField; 79cdf0e10cSrcweir using ::com::sun::star::text::XTextRange; 80cdf0e10cSrcweir using ::rtl::OString; 81cdf0e10cSrcweir using ::rtl::OStringBuffer; 82cdf0e10cSrcweir using ::rtl::OUString; 83cdf0e10cSrcweir using ::rtl::OUStringBuffer; 84cdf0e10cSrcweir using ::sax_fastparser::FSHelperPtr; 85cdf0e10cSrcweir 86cdf0e10cSrcweir DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet)); 87cdf0e10cSrcweir 88cdf0e10cSrcweir namespace oox { 89cdf0e10cSrcweir namespace drawingml { 90cdf0e10cSrcweir 91cdf0e10cSrcweir #define GETA(propName) \ 92cdf0e10cSrcweir GetProperty( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ) ) 93cdf0e10cSrcweir 94cdf0e10cSrcweir #define GETAD(propName) \ 95cdf0e10cSrcweir ( GetPropertyAndState( rXPropSet, rXPropState, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ), eState ) && eState == beans::PropertyState_DIRECT_VALUE ) 96cdf0e10cSrcweir 97cdf0e10cSrcweir #define GET(variable, propName) \ 98cdf0e10cSrcweir if ( GETA(propName) ) \ 99cdf0e10cSrcweir mAny >>= variable; 100cdf0e10cSrcweir 101cdf0e10cSrcweir // not thread safe 102cdf0e10cSrcweir int DrawingML::mnImageCounter = 1; 103cdf0e10cSrcweir 104cdf0e10cSrcweir void DrawingML::ResetCounters() 105cdf0e10cSrcweir { 106cdf0e10cSrcweir mnImageCounter = 1; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir bool DrawingML::GetProperty( Reference< XPropertySet > rXPropSet, String aName ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir bool bRetValue = false; 112cdf0e10cSrcweir 113cdf0e10cSrcweir try { 114cdf0e10cSrcweir mAny = rXPropSet->getPropertyValue( aName ); 115cdf0e10cSrcweir if ( mAny.hasValue() ) 116cdf0e10cSrcweir bRetValue = true; 117cdf0e10cSrcweir } catch( Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ } 118cdf0e10cSrcweir 119cdf0e10cSrcweir return bRetValue; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir bool DrawingML::GetPropertyAndState( Reference< XPropertySet > rXPropSet, Reference< XPropertyState > rXPropState, String aName, PropertyState& eState ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir bool bRetValue = false; 125cdf0e10cSrcweir 126cdf0e10cSrcweir try { 127cdf0e10cSrcweir mAny = rXPropSet->getPropertyValue( aName ); 128cdf0e10cSrcweir if ( mAny.hasValue() ) { 129cdf0e10cSrcweir bRetValue = true; 130cdf0e10cSrcweir eState = rXPropState->getPropertyState( aName ); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir } catch( Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ } 133cdf0e10cSrcweir 134cdf0e10cSrcweir return bRetValue; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir void DrawingML::WriteColor( sal_uInt32 nColor ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir OString sColor = OString::valueOf( ( sal_Int64 ) nColor, 16 ); 140cdf0e10cSrcweir if( sColor.getLength() < 6 ) { 141cdf0e10cSrcweir OStringBuffer sBuf( "0" ); 142cdf0e10cSrcweir int remains = 5 - sColor.getLength(); 143cdf0e10cSrcweir 144cdf0e10cSrcweir while( remains > 0 ) { 145cdf0e10cSrcweir sBuf.append( "0" ); 146cdf0e10cSrcweir remains--; 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir sBuf.append( sColor ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir sColor = sBuf.getStr(); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_srgbClr, XML_val, sColor.getStr(), FSEND ); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir void DrawingML::WriteSolidFill( sal_uInt32 nColor ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_solidFill, FSEND ); 159cdf0e10cSrcweir WriteColor( nColor ); 160cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_solidFill ); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir if ( GetProperty( rXPropSet, S( "FillColor" ) ) ) 166cdf0e10cSrcweir WriteSolidFill( *((sal_uInt32*) mAny.getValue()) & 0xffffff ); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir void DrawingML::WriteGradientStop( sal_uInt16 nStop, sal_uInt32 nColor ) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_gs, 172cdf0e10cSrcweir XML_pos, I32S( nStop * 1000 ), 173cdf0e10cSrcweir FSEND ); 174cdf0e10cSrcweir WriteColor( nColor ); 175cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_gs ); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_uInt32 DrawingML::ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir return ( ( ( nColor & 0xff ) * nIntensity ) / 100 ) 181cdf0e10cSrcweir | ( ( ( ( ( nColor & 0xff00 ) >> 8 ) * nIntensity ) / 100 ) << 8 ) 182cdf0e10cSrcweir | ( ( ( ( ( nColor & 0xff0000 ) >> 8 ) * nIntensity ) / 100 ) << 8 ); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir void DrawingML::WriteGradientFill( Reference< XPropertySet > rXPropSet ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir awt::Gradient aGradient; 188cdf0e10cSrcweir if( GETA( FillGradient ) ) { 189cdf0e10cSrcweir aGradient = *static_cast< const awt::Gradient* >( mAny.getValue() ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_gradFill, FSEND ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir switch( aGradient.Style ) { 194cdf0e10cSrcweir default: 195cdf0e10cSrcweir case GradientStyle_LINEAR: 196cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_gsLst, FSEND ); 197cdf0e10cSrcweir WriteGradientStop( 0, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) ); 198cdf0e10cSrcweir WriteGradientStop( 100, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) ); 199cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_gsLst ); 200cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_lin, 201cdf0e10cSrcweir XML_ang, I32S( ( ( ( 3600 - aGradient.Angle + 900 ) * 6000 ) % 21600000 ) ), 202cdf0e10cSrcweir FSEND ); 203cdf0e10cSrcweir break; 204cdf0e10cSrcweir 205cdf0e10cSrcweir case GradientStyle_AXIAL: 206cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_gsLst, FSEND ); 207cdf0e10cSrcweir WriteGradientStop( 0, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) ); 208cdf0e10cSrcweir WriteGradientStop( 50, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) ); 209cdf0e10cSrcweir WriteGradientStop( 100, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) ); 210cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_gsLst ); 211cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_lin, 212cdf0e10cSrcweir XML_ang, I32S( ( ( ( 3600 - aGradient.Angle + 900 ) * 6000 ) % 21600000 ) ), 213cdf0e10cSrcweir FSEND ); 214cdf0e10cSrcweir break; 215cdf0e10cSrcweir 216cdf0e10cSrcweir /* I don't see how to apply transformation to gradients, so 217cdf0e10cSrcweir * elliptical will end as radial and square as 218cdf0e10cSrcweir * rectangular. also position offsets are not applied */ 219cdf0e10cSrcweir case GradientStyle_RADIAL: 220cdf0e10cSrcweir case GradientStyle_ELLIPTICAL: 221cdf0e10cSrcweir case GradientStyle_RECT: 222cdf0e10cSrcweir case GradientStyle_SQUARE: 223cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_gsLst, FSEND ); 224cdf0e10cSrcweir WriteGradientStop( 0, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) ); 225cdf0e10cSrcweir WriteGradientStop( 100, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) ); 226cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_gsLst ); 227cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_path, 228cdf0e10cSrcweir XML_path, ( aGradient.Style == awt::GradientStyle_RADIAL || aGradient.Style == awt::GradientStyle_ELLIPTICAL ) ? "circle" : "rect", 229cdf0e10cSrcweir FSEND ); 230cdf0e10cSrcweir break; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir 233cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_gradFill ); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir void DrawingML::WriteLineArrow( Reference< XPropertySet > rXPropSet, sal_Bool bLineStart ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir ESCHER_LineEnd eLineEnd; 241cdf0e10cSrcweir sal_Int32 nArrowLength; 242cdf0e10cSrcweir sal_Int32 nArrowWidth; 243cdf0e10cSrcweir 244cdf0e10cSrcweir if ( EscherPropertyContainer::GetLineArrow( bLineStart, rXPropSet, eLineEnd, nArrowLength, nArrowWidth ) ) { 245cdf0e10cSrcweir const char* len; 246cdf0e10cSrcweir const char* type; 247cdf0e10cSrcweir const char* width; 248cdf0e10cSrcweir 249cdf0e10cSrcweir switch( nArrowLength ) { 250cdf0e10cSrcweir case ESCHER_LineShortArrow: 251cdf0e10cSrcweir len = "sm"; 252cdf0e10cSrcweir break; 253cdf0e10cSrcweir default: 254cdf0e10cSrcweir case ESCHER_LineMediumLenArrow: 255cdf0e10cSrcweir len = "med"; 256cdf0e10cSrcweir break; 257cdf0e10cSrcweir case ESCHER_LineLongArrow: 258cdf0e10cSrcweir len = "lg"; 259cdf0e10cSrcweir break; 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir switch( eLineEnd ) { 263cdf0e10cSrcweir default: 264cdf0e10cSrcweir case ESCHER_LineNoEnd: 265cdf0e10cSrcweir type = "none"; 266cdf0e10cSrcweir break; 267cdf0e10cSrcweir case ESCHER_LineArrowEnd: 268cdf0e10cSrcweir type = "triangle"; 269cdf0e10cSrcweir break; 270cdf0e10cSrcweir case ESCHER_LineArrowStealthEnd: 271cdf0e10cSrcweir type = "stealth"; 272cdf0e10cSrcweir break; 273cdf0e10cSrcweir case ESCHER_LineArrowDiamondEnd: 274cdf0e10cSrcweir type = "diamond"; 275cdf0e10cSrcweir break; 276cdf0e10cSrcweir case ESCHER_LineArrowOvalEnd: 277cdf0e10cSrcweir type = "oval"; 278cdf0e10cSrcweir break; 279cdf0e10cSrcweir case ESCHER_LineArrowOpenEnd: 280cdf0e10cSrcweir type = "arrow"; 281cdf0e10cSrcweir break; 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir switch( nArrowWidth ) { 285cdf0e10cSrcweir case ESCHER_LineNarrowArrow: 286cdf0e10cSrcweir width = "sm"; 287cdf0e10cSrcweir break; 288cdf0e10cSrcweir default: 289cdf0e10cSrcweir case ESCHER_LineMediumWidthArrow: 290cdf0e10cSrcweir width = "med"; 291cdf0e10cSrcweir break; 292cdf0e10cSrcweir case ESCHER_LineWideArrow: 293cdf0e10cSrcweir width = "lg"; 294cdf0e10cSrcweir break; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir mpFS->singleElementNS( XML_a, bLineStart ? XML_headEnd : XML_tailEnd, 298cdf0e10cSrcweir XML_len, len, 299cdf0e10cSrcweir XML_type, type, 300cdf0e10cSrcweir XML_w, width, 301cdf0e10cSrcweir FSEND ); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir drawing::LineStyle aLineStyle( drawing::LineStyle_NONE ); 308cdf0e10cSrcweir 309cdf0e10cSrcweir GET( aLineStyle, LineStyle ); 310cdf0e10cSrcweir 311cdf0e10cSrcweir if( aLineStyle == drawing::LineStyle_NONE ) 312cdf0e10cSrcweir return; 313cdf0e10cSrcweir 314cdf0e10cSrcweir sal_uInt32 nLineWidth = 0; 315cdf0e10cSrcweir sal_uInt32 nColor = 0; 316cdf0e10cSrcweir sal_Bool bColorSet = FALSE; 317cdf0e10cSrcweir const char* cap = NULL; 318cdf0e10cSrcweir drawing::LineDash aLineDash; 319cdf0e10cSrcweir sal_Bool bDashSet = FALSE; 320cdf0e10cSrcweir 321cdf0e10cSrcweir GET( nLineWidth, LineWidth ); 322cdf0e10cSrcweir 323cdf0e10cSrcweir switch( aLineStyle ) { 324cdf0e10cSrcweir case drawing::LineStyle_DASH: 325cdf0e10cSrcweir if( GETA( LineDash ) ) { 326cdf0e10cSrcweir aLineDash = *(drawing::LineDash*) mAny.getValue(); 327cdf0e10cSrcweir bDashSet = TRUE; 328cdf0e10cSrcweir if( aLineDash.Style == DashStyle_ROUND || aLineDash.Style == DashStyle_ROUNDRELATIVE ) 329cdf0e10cSrcweir cap = "rnd"; 330cdf0e10cSrcweir 331cdf0e10cSrcweir DBG(printf("dash dots: %d dashes: %d dotlen: %d dashlen: %d distance: %d\n", 332cdf0e10cSrcweir int( aLineDash.Dots ), int( aLineDash.Dashes ), int( aLineDash.DotLen ), int( aLineDash.DashLen ), int( aLineDash.Distance ))); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir /* fallthru intended */ 335cdf0e10cSrcweir case drawing::LineStyle_SOLID: 336cdf0e10cSrcweir default: 337cdf0e10cSrcweir if ( GETA( LineColor ) ) { 338cdf0e10cSrcweir nColor = *((sal_uInt32*) mAny.getValue()) & 0xffffff; 339cdf0e10cSrcweir bColorSet = TRUE; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir break; 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_ln, 345cdf0e10cSrcweir XML_cap, cap, 346cdf0e10cSrcweir XML_w, nLineWidth > 1 ? I64S( MM100toEMU( nLineWidth ) ) : NULL, 347cdf0e10cSrcweir FSEND ); 348cdf0e10cSrcweir if( bColorSet ) 349cdf0e10cSrcweir WriteSolidFill( nColor ); 350cdf0e10cSrcweir 351cdf0e10cSrcweir if( bDashSet ) { 352cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_custDash, FSEND ); 353cdf0e10cSrcweir int i; 354cdf0e10cSrcweir for( i = 0; i < aLineDash.Dots; i ++ ) 355cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_ds, 356cdf0e10cSrcweir XML_d, aLineDash.DotLen ? I64S( aLineDash.DotLen*1000 ) : "100000", 357cdf0e10cSrcweir XML_sp, I64S( aLineDash.Distance*1000 ), 358cdf0e10cSrcweir FSEND ); 359cdf0e10cSrcweir for( i = 0; i < aLineDash.Dashes; i ++ ) 360cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_ds, 361cdf0e10cSrcweir XML_d, aLineDash.DashLen ? I64S( aLineDash.DashLen*1000 ) : "100000", 362cdf0e10cSrcweir XML_sp, I64S( aLineDash.Distance*1000 ), 363cdf0e10cSrcweir FSEND ); 364cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_custDash ); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir if( nLineWidth > 1 && GETA( LineJoint ) ) { 368cdf0e10cSrcweir LineJoint eLineJoint; 369cdf0e10cSrcweir 370cdf0e10cSrcweir mAny >>= eLineJoint; 371cdf0e10cSrcweir switch( eLineJoint ) { 372cdf0e10cSrcweir case LineJoint_NONE: 373cdf0e10cSrcweir case LineJoint_MIDDLE: 374cdf0e10cSrcweir case LineJoint_BEVEL: 375cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_bevel, FSEND ); 376cdf0e10cSrcweir break; 377cdf0e10cSrcweir default: 378cdf0e10cSrcweir case LineJoint_MITER: 379cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_miter, FSEND ); 380cdf0e10cSrcweir break; 381cdf0e10cSrcweir case LineJoint_ROUND: 382cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_round, FSEND ); 383cdf0e10cSrcweir break; 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir WriteLineArrow( rXPropSet, sal_True ); 388cdf0e10cSrcweir WriteLineArrow( rXPropSet, sal_False ); 389cdf0e10cSrcweir 390cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_ln ); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir OUString DrawingML::WriteImage( const OUString& rURL ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir ByteString aURLBS( UniString( rURL ), RTL_TEXTENCODING_UTF8 ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; 398cdf0e10cSrcweir int index = aURLBS.Search( aURLBegin ); 399cdf0e10cSrcweir 400cdf0e10cSrcweir if ( index != STRING_NOTFOUND ) { 401cdf0e10cSrcweir DBG(printf ("begin: %ld %s\n", long( sizeof( aURLBegin ) ), USS( rURL ) + sizeof( aURLBegin ) - 1 )); 402cdf0e10cSrcweir aURLBS.Erase( 0, sizeof( aURLBegin ) - 1 ); 403cdf0e10cSrcweir Graphic aGraphic = GraphicObject( aURLBS ).GetTransformedGraphic (); 404cdf0e10cSrcweir 405cdf0e10cSrcweir return WriteImage( aGraphic ); 406cdf0e10cSrcweir } else { 407cdf0e10cSrcweir // add link to relations 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir return OUString(); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir OUString DrawingML::WriteImage( const Graphic& rGraphic ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir GfxLink aLink = rGraphic.GetLink (); 416cdf0e10cSrcweir OUString sMediaType; 417cdf0e10cSrcweir const char* sExtension = NULL; 418cdf0e10cSrcweir OUString sRelId; 419cdf0e10cSrcweir 420cdf0e10cSrcweir SvMemoryStream aStream; 421cdf0e10cSrcweir const void* aData = aLink.GetData(); 422cdf0e10cSrcweir sal_Size nDataSize = aLink.GetDataSize(); 423cdf0e10cSrcweir 424cdf0e10cSrcweir switch ( aLink.GetType() ) { 425cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_GIF: 426cdf0e10cSrcweir sMediaType = US( "image/gif" ); 427cdf0e10cSrcweir sExtension = ".gif"; 428cdf0e10cSrcweir break; 42972583341SArmin Le Grand 43072583341SArmin Le Grand // #15508# added BMP type for better exports 43172583341SArmin Le Grand // export not yet active, so adding for reference (not checked) 43272583341SArmin Le Grand case GFX_LINK_TYPE_NATIVE_BMP: 43372583341SArmin Le Grand sMediaType = US( "image/bmp" ); 43472583341SArmin Le Grand sExtension = ".bmp"; 43572583341SArmin Le Grand break; 43672583341SArmin Le Grand 437cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_JPG: 438cdf0e10cSrcweir sMediaType = US( "image/jpeg" ); 439cdf0e10cSrcweir sExtension = ".jpeg"; 440cdf0e10cSrcweir break; 441cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_PNG: 442cdf0e10cSrcweir sMediaType = US( "image/png" ); 443cdf0e10cSrcweir sExtension = ".png"; 444cdf0e10cSrcweir break; 445cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_TIF: 446cdf0e10cSrcweir sMediaType = US( "image/tiff" ); 447cdf0e10cSrcweir sExtension = ".tiff"; 448cdf0e10cSrcweir break; 449cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_WMF: 450cdf0e10cSrcweir sMediaType = US( "image/x-wmf" ); 451cdf0e10cSrcweir sExtension = ".wmf"; 452cdf0e10cSrcweir break; 453cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_MET: 454cdf0e10cSrcweir sMediaType = US( "image/x-met" ); 455cdf0e10cSrcweir sExtension = ".met"; 456cdf0e10cSrcweir break; 457cdf0e10cSrcweir case GFX_LINK_TYPE_NATIVE_PCT: 458cdf0e10cSrcweir sMediaType = US( "image/x-pict" ); 459cdf0e10cSrcweir sExtension = ".pct"; 460cdf0e10cSrcweir break; 461cdf0e10cSrcweir default: { 462cdf0e10cSrcweir GraphicType aType = rGraphic.GetType(); 463cdf0e10cSrcweir if ( aType == GRAPHIC_BITMAP ) { 464cdf0e10cSrcweir GraphicConverter::Export( aStream, rGraphic, CVT_PNG ); 465cdf0e10cSrcweir sMediaType = US( "image/png" ); 466cdf0e10cSrcweir sExtension = ".png"; 467cdf0e10cSrcweir } else if ( aType == GRAPHIC_GDIMETAFILE ) { 468cdf0e10cSrcweir GraphicConverter::Export( aStream, rGraphic, CVT_EMF ); 469cdf0e10cSrcweir sMediaType = US( "image/x-emf" ); 470cdf0e10cSrcweir sExtension = ".emf"; 471cdf0e10cSrcweir } else { 472cdf0e10cSrcweir OSL_TRACE( "unhandled graphic type" ); 473cdf0e10cSrcweir break; 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir aData = aStream.GetData(); 477cdf0e10cSrcweir nDataSize = aStream.GetSize(); 478cdf0e10cSrcweir break; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir const char *pComponent = NULL; 483cdf0e10cSrcweir switch ( meDocumentType ) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir case DOCUMENT_DOCX: pComponent = "word"; break; 486cdf0e10cSrcweir case DOCUMENT_PPTX: pComponent = "ppt"; break; 487cdf0e10cSrcweir case DOCUMENT_XLSX: pComponent = "xl"; break; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 490cdf0e10cSrcweir Reference< XOutputStream > xOutStream = mpFB->openOutputStream( OUStringBuffer() 491cdf0e10cSrcweir .appendAscii( pComponent ) 492cdf0e10cSrcweir .appendAscii( "/media/image" ) 493cdf0e10cSrcweir .append( (sal_Int32) mnImageCounter ) 494cdf0e10cSrcweir .appendAscii( sExtension ) 495cdf0e10cSrcweir .makeStringAndClear(), 496cdf0e10cSrcweir sMediaType ); 497cdf0e10cSrcweir xOutStream->writeBytes( Sequence< sal_Int8 >( (const sal_Int8*) aData, nDataSize ) ); 498cdf0e10cSrcweir xOutStream->closeOutput(); 499cdf0e10cSrcweir 500cdf0e10cSrcweir const char *pImagePrefix = NULL; 501cdf0e10cSrcweir switch ( meDocumentType ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir case DOCUMENT_DOCX: 504cdf0e10cSrcweir pImagePrefix = "media/image"; 505cdf0e10cSrcweir break; 506cdf0e10cSrcweir case DOCUMENT_PPTX: 507cdf0e10cSrcweir case DOCUMENT_XLSX: 508cdf0e10cSrcweir pImagePrefix = "../media/image"; 509cdf0e10cSrcweir break; 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir sRelId = mpFB->addRelation( mpFS->getOutputStream(), 513cdf0e10cSrcweir US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" ), 514cdf0e10cSrcweir OUStringBuffer() 515cdf0e10cSrcweir .appendAscii( pImagePrefix ) 516cdf0e10cSrcweir .append( (sal_Int32) mnImageCounter ++ ) 517cdf0e10cSrcweir .appendAscii( sExtension ) 518cdf0e10cSrcweir .makeStringAndClear() ); 519cdf0e10cSrcweir 520cdf0e10cSrcweir return sRelId; 521cdf0e10cSrcweir } 522cdf0e10cSrcweir 523cdf0e10cSrcweir OUString DrawingML::WriteBlip( OUString& rURL ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir OUString sRelId = WriteImage( rURL ); 526cdf0e10cSrcweir 527cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_blip, 528cdf0e10cSrcweir FSNS( XML_r, XML_embed), OUStringToOString( sRelId, RTL_TEXTENCODING_UTF8 ).getStr(), 529cdf0e10cSrcweir FSEND ); 530cdf0e10cSrcweir 531cdf0e10cSrcweir return sRelId; 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir void DrawingML::WriteBlipMode( Reference< XPropertySet > rXPropSet ) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir BitmapMode eBitmapMode( BitmapMode_NO_REPEAT ); 537cdf0e10cSrcweir if (GetProperty( rXPropSet, S( "FillBitmapMode" ) ) ) 538cdf0e10cSrcweir mAny >>= eBitmapMode; 539cdf0e10cSrcweir 540cdf0e10cSrcweir DBG(printf("fill bitmap mode: %d\n", eBitmapMode)); 541cdf0e10cSrcweir 542cdf0e10cSrcweir switch (eBitmapMode) { 543cdf0e10cSrcweir case BitmapMode_REPEAT: 544cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_tile, FSEND ); 545cdf0e10cSrcweir break; 546cdf0e10cSrcweir default: 547cdf0e10cSrcweir ; 548cdf0e10cSrcweir } 549cdf0e10cSrcweir } 550cdf0e10cSrcweir 551cdf0e10cSrcweir void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, String sURLPropName ) 552cdf0e10cSrcweir { 553cdf0e10cSrcweir WriteBlipFill( rXPropSet, sURLPropName, XML_a ); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, String sURLPropName, sal_Int32 nXmlNamespace ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir if ( GetProperty( rXPropSet, sURLPropName ) ) { 559cdf0e10cSrcweir OUString aURL; 560cdf0e10cSrcweir mAny >>= aURL; 561cdf0e10cSrcweir 562cdf0e10cSrcweir DBG(printf ("URL: %s\n", OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() )); 563cdf0e10cSrcweir 564cdf0e10cSrcweir if( !aURL.getLength() ) 565cdf0e10cSrcweir return; 566cdf0e10cSrcweir 567cdf0e10cSrcweir mpFS->startElementNS( nXmlNamespace , XML_blipFill, FSEND ); 568cdf0e10cSrcweir 569cdf0e10cSrcweir WriteBlip( aURL ); 570cdf0e10cSrcweir 571cdf0e10cSrcweir if( sURLPropName == S( "FillBitmapURL" ) ) 572cdf0e10cSrcweir WriteBlipMode( rXPropSet ); 573cdf0e10cSrcweir else if( GetProperty( rXPropSet, S( "FillBitmapStretch" ) ) ) { 574cdf0e10cSrcweir bool bStretch = false; 575cdf0e10cSrcweir mAny >>= bStretch; 576cdf0e10cSrcweir 577cdf0e10cSrcweir if( bStretch ) 578cdf0e10cSrcweir WriteStretch(); 579cdf0e10cSrcweir } 580cdf0e10cSrcweir 581cdf0e10cSrcweir mpFS->endElementNS( nXmlNamespace, XML_blipFill ); 582cdf0e10cSrcweir } 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585cdf0e10cSrcweir void DrawingML::WriteStretch() 586cdf0e10cSrcweir { 587cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_stretch, FSEND ); 588cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_fillRect, FSEND ); 589cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_stretch ); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir 592cdf0e10cSrcweir void DrawingML::WriteTransformation( const Rectangle& rRect, 593cdf0e10cSrcweir sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation ) 594cdf0e10cSrcweir { 595cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_xfrm, 596cdf0e10cSrcweir XML_flipH, bFlipH ? "1" : NULL, 597cdf0e10cSrcweir XML_flipV, bFlipV ? "1" : NULL, 598cdf0e10cSrcweir XML_rot, nRotation ? I32S( nRotation ) : NULL, 599cdf0e10cSrcweir FSEND ); 600cdf0e10cSrcweir 601cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_off, XML_x, IS( MM100toEMU( rRect.Left() ) ), XML_y, IS( MM100toEMU( rRect.Top() ) ), FSEND ); 602cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_ext, XML_cx, IS( MM100toEMU( rRect.GetWidth() ) ), XML_cy, IS( MM100toEMU( rRect.GetHeight() ) ), FSEND ); 603cdf0e10cSrcweir 604cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_xfrm ); 605cdf0e10cSrcweir } 606cdf0e10cSrcweir 607cdf0e10cSrcweir void DrawingML::WriteShapeTransformation( Reference< XShape > rXShape, sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation ) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir DBG(printf( "write shape transformation\n" )); 610cdf0e10cSrcweir 611cdf0e10cSrcweir awt::Point aPos = rXShape->getPosition(); 612cdf0e10cSrcweir awt::Size aSize = rXShape->getSize(); 613cdf0e10cSrcweir 614cdf0e10cSrcweir WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), bFlipH, bFlipV, nRotation ); 615cdf0e10cSrcweir } 616cdf0e10cSrcweir 617cdf0e10cSrcweir void DrawingML::WriteRunProperties( Reference< XTextRange > rRun ) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY ); 620cdf0e10cSrcweir Reference< XPropertyState > rXPropState( rRun, UNO_QUERY ); 621cdf0e10cSrcweir OUString usLanguage; 622cdf0e10cSrcweir PropertyState eState; 623cdf0e10cSrcweir sal_Int16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguage() ); 624cdf0e10cSrcweir sal_Bool bComplex = ( nScriptType == ScriptType::COMPLEX ); 625cdf0e10cSrcweir const char* bold = NULL; 626cdf0e10cSrcweir const char* italic = NULL; 627cdf0e10cSrcweir const char* underline = NULL; 628cdf0e10cSrcweir sal_Int32 nSize = 1800; 629cdf0e10cSrcweir 630cdf0e10cSrcweir if( GETAD( CharHeight ) ) 631cdf0e10cSrcweir nSize = (sal_Int32) (100*(*((float*) mAny.getValue()))); 632cdf0e10cSrcweir 633cdf0e10cSrcweir if ( ( bComplex && GETAD( CharWeightComplex ) ) || GETAD( CharWeight ) ) 634cdf0e10cSrcweir if ( *((float*) mAny.getValue()) >= awt::FontWeight::SEMIBOLD ) 635cdf0e10cSrcweir bold = "1"; 636cdf0e10cSrcweir 637cdf0e10cSrcweir if ( ( bComplex && GETAD( CharPostureComplex ) ) || GETAD( CharPosture ) ) 638cdf0e10cSrcweir switch ( *((awt::FontSlant*) mAny.getValue()) ) 639cdf0e10cSrcweir { 640cdf0e10cSrcweir case awt::FontSlant_OBLIQUE : 641cdf0e10cSrcweir case awt::FontSlant_ITALIC : 642cdf0e10cSrcweir italic = "1"; 643cdf0e10cSrcweir break; 644cdf0e10cSrcweir default: 645cdf0e10cSrcweir break; 646cdf0e10cSrcweir } 647cdf0e10cSrcweir 648cdf0e10cSrcweir if ( GETAD( CharUnderline ) ) 649cdf0e10cSrcweir switch ( *((sal_Int16*) mAny.getValue()) ) 650cdf0e10cSrcweir { 651cdf0e10cSrcweir case awt::FontUnderline::SINGLE : 652cdf0e10cSrcweir underline = "sng"; 653cdf0e10cSrcweir break; 654cdf0e10cSrcweir case awt::FontUnderline::DOUBLE : 655cdf0e10cSrcweir underline = "dbl"; 656cdf0e10cSrcweir break; 657cdf0e10cSrcweir case awt::FontUnderline::DOTTED : 658cdf0e10cSrcweir underline = "dotted"; 659cdf0e10cSrcweir break; 660cdf0e10cSrcweir case awt::FontUnderline::DASH : 661cdf0e10cSrcweir underline = "dash"; 662cdf0e10cSrcweir break; 663cdf0e10cSrcweir case awt::FontUnderline::LONGDASH : 664cdf0e10cSrcweir underline = "dashLong"; 665cdf0e10cSrcweir break; 666cdf0e10cSrcweir case awt::FontUnderline::DASHDOT : 667cdf0e10cSrcweir underline = "dotDash"; 668cdf0e10cSrcweir break; 669cdf0e10cSrcweir case awt::FontUnderline::DASHDOTDOT : 670cdf0e10cSrcweir underline = "dotDotDash"; 671cdf0e10cSrcweir break; 672cdf0e10cSrcweir case awt::FontUnderline::WAVE : 673cdf0e10cSrcweir underline = "wavy"; 674cdf0e10cSrcweir break; 675cdf0e10cSrcweir case awt::FontUnderline::DOUBLEWAVE : 676cdf0e10cSrcweir underline = "wavyDbl"; 677cdf0e10cSrcweir break; 678cdf0e10cSrcweir case awt::FontUnderline::BOLD : 679cdf0e10cSrcweir underline = "heavy"; 680cdf0e10cSrcweir break; 681cdf0e10cSrcweir case awt::FontUnderline::BOLDDOTTED : 682cdf0e10cSrcweir underline = "dottedHeavy"; 683cdf0e10cSrcweir break; 684cdf0e10cSrcweir case awt::FontUnderline::BOLDDASH : 685cdf0e10cSrcweir underline = "dashHeavy"; 686cdf0e10cSrcweir break; 687cdf0e10cSrcweir case awt::FontUnderline::BOLDLONGDASH : 688cdf0e10cSrcweir underline = "dashLongHeavy"; 689cdf0e10cSrcweir break; 690cdf0e10cSrcweir case awt::FontUnderline::BOLDDASHDOT : 691cdf0e10cSrcweir underline = "dotDashHeavy"; 692cdf0e10cSrcweir break; 693cdf0e10cSrcweir case awt::FontUnderline::BOLDDASHDOTDOT : 694cdf0e10cSrcweir underline = "dotDotDashHeavy"; 695cdf0e10cSrcweir break; 696cdf0e10cSrcweir case awt::FontUnderline::BOLDWAVE : 697cdf0e10cSrcweir underline = "wavyHeavy"; 698cdf0e10cSrcweir break; 699cdf0e10cSrcweir } 700cdf0e10cSrcweir 701cdf0e10cSrcweir if( GETA( CharLocale ) ) { 702cdf0e10cSrcweir com::sun::star::lang::Locale eLocale; 703cdf0e10cSrcweir mAny >>= eLocale; 704cdf0e10cSrcweir 705cdf0e10cSrcweir OUStringBuffer usLanguageBuffer = eLocale.Language; 706cdf0e10cSrcweir if( eLocale.Country.getLength() ) { 707cdf0e10cSrcweir usLanguageBuffer.appendAscii( "-" ); 708cdf0e10cSrcweir usLanguageBuffer.append( eLocale.Country ); 709cdf0e10cSrcweir } 710cdf0e10cSrcweir 711cdf0e10cSrcweir if( usLanguageBuffer.getLength() ) 712cdf0e10cSrcweir usLanguage = usLanguageBuffer.makeStringAndClear(); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_rPr, 716cdf0e10cSrcweir XML_b, bold, 717cdf0e10cSrcweir XML_i, italic, 718cdf0e10cSrcweir XML_lang, usLanguage.getLength() ? USS( usLanguage ) : NULL, 719cdf0e10cSrcweir XML_sz, nSize == 1800 ? NULL : IS( nSize ), 720cdf0e10cSrcweir XML_u, underline, 721cdf0e10cSrcweir FSEND ); 722cdf0e10cSrcweir 723cdf0e10cSrcweir // mso doesn't like text color to be placed after typeface 724cdf0e10cSrcweir if( GETAD( CharColor ) ) { 725cdf0e10cSrcweir sal_uInt32 color = *((sal_uInt32*) mAny.getValue()); 726cdf0e10cSrcweir DBG(printf("run color: %x auto: %x\n", static_cast<unsigned int>( color ), static_cast<unsigned int>( COL_AUTO ))); 727cdf0e10cSrcweir 728cdf0e10cSrcweir if( color == COL_AUTO ) { // nCharColor depends to the background color 729cdf0e10cSrcweir sal_Bool bIsDark = sal_False; 730cdf0e10cSrcweir GET( bIsDark, IsBackgroundDark ); 731cdf0e10cSrcweir color = bIsDark ? 0xffffff : 0x000000; 732cdf0e10cSrcweir } 733cdf0e10cSrcweir color &= 0xffffff; 734cdf0e10cSrcweir 735cdf0e10cSrcweir // TODO: special handle embossed/engraved 736cdf0e10cSrcweir 737cdf0e10cSrcweir WriteSolidFill( color ); 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir if( GETAD( CharFontName ) ) { 741cdf0e10cSrcweir const char* typeface = NULL; 742cdf0e10cSrcweir const char* pitch = NULL; 743cdf0e10cSrcweir const char* charset = NULL; 744cdf0e10cSrcweir OUString usTypeface, usPitch, usCharset; 745cdf0e10cSrcweir 746cdf0e10cSrcweir mAny >>= usTypeface; 747cdf0e10cSrcweir String aSubstName( GetSubsFontName( usTypeface, SUBSFONT_ONLYONE | SUBSFONT_MS ) ); 748cdf0e10cSrcweir if( aSubstName.Len() ) 749cdf0e10cSrcweir typeface = ST( aSubstName ); 750cdf0e10cSrcweir else 751cdf0e10cSrcweir typeface = USS( usTypeface ); 752cdf0e10cSrcweir 753cdf0e10cSrcweir 754cdf0e10cSrcweir 755cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_latin, 756cdf0e10cSrcweir XML_typeface, typeface, 757cdf0e10cSrcweir XML_pitchFamily, pitch, 758cdf0e10cSrcweir XML_charset, charset, 759cdf0e10cSrcweir FSEND ); 760cdf0e10cSrcweir } 761cdf0e10cSrcweir 762cdf0e10cSrcweir if( ( bComplex && GETAD( CharFontNameComplex ) ) || ( !bComplex && GETAD( CharFontNameAsian ) ) ) { 763cdf0e10cSrcweir const char* typeface = NULL; 764cdf0e10cSrcweir const char* pitch = NULL; 765cdf0e10cSrcweir const char* charset = NULL; 766cdf0e10cSrcweir OUString usTypeface, usPitch, usCharset; 767cdf0e10cSrcweir 768cdf0e10cSrcweir mAny >>= usTypeface; 769cdf0e10cSrcweir String aSubstName( GetSubsFontName( usTypeface, SUBSFONT_ONLYONE | SUBSFONT_MS ) ); 770cdf0e10cSrcweir if( aSubstName.Len() ) 771cdf0e10cSrcweir typeface = ST( aSubstName ); 772cdf0e10cSrcweir else 773cdf0e10cSrcweir typeface = USS( usTypeface ); 774cdf0e10cSrcweir 775cdf0e10cSrcweir mpFS->singleElementNS( XML_a, bComplex ? XML_cs : XML_ea, 776cdf0e10cSrcweir XML_typeface, typeface, 777cdf0e10cSrcweir XML_pitchFamily, pitch, 778cdf0e10cSrcweir XML_charset, charset, 779cdf0e10cSrcweir FSEND ); 780cdf0e10cSrcweir } 781cdf0e10cSrcweir 782cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_rPr ); 783cdf0e10cSrcweir } 784cdf0e10cSrcweir 785cdf0e10cSrcweir const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun ) 786cdf0e10cSrcweir { 787cdf0e10cSrcweir const char* sType = NULL; 788cdf0e10cSrcweir Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY ); 789cdf0e10cSrcweir String aFieldType; 790cdf0e10cSrcweir 791cdf0e10cSrcweir if( GETA( TextPortionType ) ) { 792cdf0e10cSrcweir aFieldType = String( *(::rtl::OUString*)mAny.getValue() ); 793cdf0e10cSrcweir DBG(printf ("field type: %s\n", ST(aFieldType) )); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir 796cdf0e10cSrcweir if( aFieldType == S( "TextField" ) ) { 797cdf0e10cSrcweir Reference< XTextField > rXTextField; 798cdf0e10cSrcweir GET( rXTextField, TextField ); 799cdf0e10cSrcweir if( rXTextField.is() ) { 800cdf0e10cSrcweir rXPropSet.set( rXTextField, UNO_QUERY ); 801cdf0e10cSrcweir if( rXPropSet.is() ) { 802cdf0e10cSrcweir String aFieldKind( rXTextField->getPresentation( TRUE ) ); 803cdf0e10cSrcweir DBG(printf ("field kind: %s\n", ST(aFieldKind) )); 804cdf0e10cSrcweir if( aFieldKind == S( "Page" ) ) { 805cdf0e10cSrcweir return "slidenum"; 806cdf0e10cSrcweir } 807cdf0e10cSrcweir } 808cdf0e10cSrcweir } 809cdf0e10cSrcweir } 810cdf0e10cSrcweir 811cdf0e10cSrcweir return sType; 812cdf0e10cSrcweir } 813cdf0e10cSrcweir 814cdf0e10cSrcweir void DrawingML::GetUUID( OStringBuffer& rBuffer ) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir Sequence< sal_uInt8 > aSeq( 16 ); 817cdf0e10cSrcweir static char cDigits[17] = "0123456789ABCDEF"; 818cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 819cdf0e10cSrcweir int i; 820cdf0e10cSrcweir 821cdf0e10cSrcweir rBuffer.append( '{' ); 822cdf0e10cSrcweir for( i = 0; i < 4; i++ ) { 823cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] >> 4 ] ); 824cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] && 0xf ] ); 825cdf0e10cSrcweir } 826cdf0e10cSrcweir rBuffer.append( '-' ); 827cdf0e10cSrcweir for( ; i < 6; i++ ) { 828cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] >> 4 ] ); 829cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] && 0xf ] ); 830cdf0e10cSrcweir } 831cdf0e10cSrcweir rBuffer.append( '-' ); 832cdf0e10cSrcweir for( ; i < 8; i++ ) { 833cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] >> 4 ] ); 834cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] && 0xf ] ); 835cdf0e10cSrcweir } 836cdf0e10cSrcweir rBuffer.append( '-' ); 837cdf0e10cSrcweir for( ; i < 10; i++ ) { 838cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] >> 4 ] ); 839cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] && 0xf ] ); 840cdf0e10cSrcweir } 841cdf0e10cSrcweir rBuffer.append( '-' ); 842cdf0e10cSrcweir for( ; i < 16; i++ ) { 843cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] >> 4 ] ); 844cdf0e10cSrcweir rBuffer.append( cDigits[ aSeq[i] && 0xf ] ); 845cdf0e10cSrcweir } 846cdf0e10cSrcweir rBuffer.append( '}' ); 847cdf0e10cSrcweir } 848cdf0e10cSrcweir 849cdf0e10cSrcweir void DrawingML::WriteRun( Reference< XTextRange > rRun ) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir const char* sFieldType; 852cdf0e10cSrcweir bool bIsField = false; 853cdf0e10cSrcweir OUString sText = rRun->getString(); 854cdf0e10cSrcweir 855cdf0e10cSrcweir if( sText.getLength() < 1) 856cdf0e10cSrcweir return; 857cdf0e10cSrcweir 858cdf0e10cSrcweir if( ( sFieldType = GetFieldType( rRun ) ) ) { 859cdf0e10cSrcweir OStringBuffer sUUID(39); 860cdf0e10cSrcweir 861cdf0e10cSrcweir GetUUID( sUUID ); 862cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_fld, 863cdf0e10cSrcweir XML_id, sUUID.getStr(), 864cdf0e10cSrcweir XML_type, sFieldType, 865cdf0e10cSrcweir FSEND ); 866cdf0e10cSrcweir bIsField = true; 867cdf0e10cSrcweir } else 868cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_r, FSEND ); 869cdf0e10cSrcweir 870cdf0e10cSrcweir WriteRunProperties( rRun ); 871cdf0e10cSrcweir 872cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_t, FSEND ); 873cdf0e10cSrcweir mpFS->writeEscaped( sText ); 874cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_t ); 875cdf0e10cSrcweir 876cdf0e10cSrcweir if( bIsField ) 877cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_fld ); 878cdf0e10cSrcweir else 879cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_r ); 880cdf0e10cSrcweir } 881cdf0e10cSrcweir 882cdf0e10cSrcweir #define AUTONUM(x) \ 883cdf0e10cSrcweir if( bPBoth ) \ 884cdf0e10cSrcweir pAutoNumType = #x "ParenBoth"; \ 885cdf0e10cSrcweir else if( bPBehind ) \ 886cdf0e10cSrcweir pAutoNumType = #x "ParenR"; \ 887cdf0e10cSrcweir else if( bSDot ) \ 888cdf0e10cSrcweir pAutoNumType = #x "Period"; 889cdf0e10cSrcweir 890cdf0e10cSrcweir 891cdf0e10cSrcweir inline static const char* GetAutoNumType( sal_Int16 nNumberingType, bool bSDot, bool bPBehind, bool bPBoth ) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir const char* pAutoNumType = NULL; 894cdf0e10cSrcweir 895cdf0e10cSrcweir switch( (SvxExtNumType)nNumberingType ) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir case SVX_NUM_CHARS_UPPER_LETTER_N : 898cdf0e10cSrcweir case SVX_NUM_CHARS_UPPER_LETTER : 899cdf0e10cSrcweir AUTONUM( alphaUc ); 900cdf0e10cSrcweir break; 901cdf0e10cSrcweir case SVX_NUM_CHARS_LOWER_LETTER_N : 902cdf0e10cSrcweir case SVX_NUM_CHARS_LOWER_LETTER : 903cdf0e10cSrcweir AUTONUM( alphaLc ); 904cdf0e10cSrcweir break; 905cdf0e10cSrcweir case SVX_NUM_ROMAN_UPPER : 906cdf0e10cSrcweir AUTONUM( romanUc ); 907cdf0e10cSrcweir break; 908cdf0e10cSrcweir case SVX_NUM_ROMAN_LOWER : 909cdf0e10cSrcweir AUTONUM( romanLc ); 910cdf0e10cSrcweir break; 911cdf0e10cSrcweir case SVX_NUM_ARABIC : 912cdf0e10cSrcweir AUTONUM( arabic ) 913cdf0e10cSrcweir else 914cdf0e10cSrcweir pAutoNumType = "arabicPlain"; 915cdf0e10cSrcweir break; 916cdf0e10cSrcweir default: 917cdf0e10cSrcweir break; 918cdf0e10cSrcweir } 919cdf0e10cSrcweir 920cdf0e10cSrcweir return pAutoNumType; 921cdf0e10cSrcweir } 922cdf0e10cSrcweir 923cdf0e10cSrcweir void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sal_Int16 nLevel ) 924cdf0e10cSrcweir { 925cdf0e10cSrcweir if( nLevel >= 0 && GETA( NumberingRules ) ) 926cdf0e10cSrcweir { 927cdf0e10cSrcweir Reference< XIndexAccess > rXIndexAccess; 928cdf0e10cSrcweir 929cdf0e10cSrcweir if ( ( mAny >>= rXIndexAccess ) && nLevel < rXIndexAccess->getCount() ) 930cdf0e10cSrcweir { 931cdf0e10cSrcweir DBG(printf ("numbering rules\n")); 932cdf0e10cSrcweir 933cdf0e10cSrcweir Sequence< PropertyValue > aPropertySequence; 934cdf0e10cSrcweir rXIndexAccess->getByIndex( nLevel ) >>= aPropertySequence; 935cdf0e10cSrcweir 936cdf0e10cSrcweir 937cdf0e10cSrcweir const PropertyValue* pPropValue = aPropertySequence.getArray(); 938cdf0e10cSrcweir 939cdf0e10cSrcweir sal_Int32 nPropertyCount = aPropertySequence.getLength(); 940cdf0e10cSrcweir 941cdf0e10cSrcweir if ( nPropertyCount ) { 942cdf0e10cSrcweir 943cdf0e10cSrcweir sal_Int16 nNumberingType = -1; 944cdf0e10cSrcweir bool bSDot = false; 945cdf0e10cSrcweir bool bPBehind = false; 946cdf0e10cSrcweir bool bPBoth = false; 947cdf0e10cSrcweir sal_Unicode aBulletChar = 0x2022; // a bullet 948cdf0e10cSrcweir awt::FontDescriptor aFontDesc; 949cdf0e10cSrcweir bool bHasFontDesc = false; 950cdf0e10cSrcweir OUString aGraphicURL; 951cdf0e10cSrcweir sal_Int16 nBulletRelSize = 0; 952cdf0e10cSrcweir 953cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nPropertyCount; i++ ) { 954cdf0e10cSrcweir const void* pValue = pPropValue[ i ].Value.getValue(); 955cdf0e10cSrcweir if ( pValue ) { 956cdf0e10cSrcweir OUString aPropName( pPropValue[ i ].Name ); 957cdf0e10cSrcweir DBG(printf ("pro name: %s\n", OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ).getStr())); 958cdf0e10cSrcweir if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "NumberingType" ) ) ) 959cdf0e10cSrcweir nNumberingType = *( (sal_Int16*)pValue ); 960cdf0e10cSrcweir else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Prefix" ) ) ) { 961cdf0e10cSrcweir if( *(OUString*)pValue == US( ")" ) ) 962cdf0e10cSrcweir bPBoth = true; 963cdf0e10cSrcweir } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Suffix" ) ) ) { 964cdf0e10cSrcweir if( *(OUString*)pValue == US( "." ) ) 965cdf0e10cSrcweir bSDot = true; 966cdf0e10cSrcweir else if( *(OUString*)pValue == US( ")" ) ) 967cdf0e10cSrcweir bPBehind = true; 968cdf0e10cSrcweir } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletChar" ) ) ) 969cdf0e10cSrcweir { 970cdf0e10cSrcweir aBulletChar = String ( *( (String*)pValue ) ).GetChar( 0 ); 971cdf0e10cSrcweir //printf ("bullet char: %d\n", aBulletChar.getStr()); 972cdf0e10cSrcweir } 973cdf0e10cSrcweir else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletFont" ) ) ) 974cdf0e10cSrcweir { 975cdf0e10cSrcweir aFontDesc = *( (awt::FontDescriptor*)pValue ); 976cdf0e10cSrcweir bHasFontDesc = true; 977cdf0e10cSrcweir 978cdf0e10cSrcweir // Our numbullet dialog has set the wrong textencoding for our "StarSymbol" font, 979cdf0e10cSrcweir // instead of a Unicode encoding the encoding RTL_TEXTENCODING_SYMBOL was used. 980cdf0e10cSrcweir // Because there might exist a lot of damaged documemts I added this two lines 981cdf0e10cSrcweir // which fixes the bullet problem for the export. 982cdf0e10cSrcweir if ( aFontDesc.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ) ) 983cdf0e10cSrcweir aFontDesc.CharSet = RTL_TEXTENCODING_MS_1252; 984cdf0e10cSrcweir 985cdf0e10cSrcweir } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletRelSize" ) ) ) { 986cdf0e10cSrcweir nBulletRelSize = *( (sal_Int16*)pValue ); 987cdf0e10cSrcweir } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicURL" ) ) ) { 988cdf0e10cSrcweir aGraphicURL = ( *(OUString*)pValue ); 989cdf0e10cSrcweir DBG(printf ("graphic url: %s\n", OUStringToOString( aGraphicURL, RTL_TEXTENCODING_UTF8 ).getStr())); 990cdf0e10cSrcweir } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicSize" ) ) ) 991cdf0e10cSrcweir { 992cdf0e10cSrcweir if ( pPropValue[ i ].Value.getValueType() == ::getCppuType( (awt::Size*)0) ) 993cdf0e10cSrcweir { 994cdf0e10cSrcweir // don't cast awt::Size to Size as on 64-bits they are not the same. 995cdf0e10cSrcweir ::com::sun::star::awt::Size aSize; 996cdf0e10cSrcweir pPropValue[ i ].Value >>= aSize; 997cdf0e10cSrcweir //aBuGraSize.nA = aSize.Width; 998cdf0e10cSrcweir //aBuGraSize.nB = aSize.Height; 999cdf0e10cSrcweir DBG(printf("graphic size: %dx%d\n", int( aSize.Width ), int( aSize.Height ))); 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir } 1002cdf0e10cSrcweir } 1003cdf0e10cSrcweir } 1004cdf0e10cSrcweir 1005cdf0e10cSrcweir const char* pAutoNumType = GetAutoNumType( nNumberingType, bSDot, bPBehind, bPBoth ); 1006cdf0e10cSrcweir 1007cdf0e10cSrcweir if( nLevel >= 0 ) { 1008cdf0e10cSrcweir if( aGraphicURL.getLength() > 0 ) { 1009cdf0e10cSrcweir OUString sRelId = WriteImage( aGraphicURL ); 1010cdf0e10cSrcweir 1011cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_buBlip, FSEND ); 1012cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_blip, FSNS( XML_r, XML_embed ), USS( sRelId ), FSEND ); 1013cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_buBlip ); 1014cdf0e10cSrcweir } else { 1015cdf0e10cSrcweir if( nBulletRelSize && nBulletRelSize != 100 ) 1016cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_buSzPct, 1017cdf0e10cSrcweir XML_val, IS( 1000*( (sal_Int32)nBulletRelSize ) ), FSEND ); 1018cdf0e10cSrcweir if( bHasFontDesc ) 1019cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_buFont, 1020cdf0e10cSrcweir XML_typeface, OUStringToOString( aFontDesc.Name, RTL_TEXTENCODING_UTF8 ).getStr(), 1021cdf0e10cSrcweir XML_charset, (aFontDesc.CharSet == awt::CharSet::SYMBOL) ? "2" : NULL, 1022cdf0e10cSrcweir FSEND ); 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir if( pAutoNumType ) 1025cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_buAutoNum, XML_type, pAutoNumType, FSEND ); 1026cdf0e10cSrcweir else { 1027cdf0e10cSrcweir aBulletChar = SubstituteBullet( aBulletChar, aFontDesc ); 1028cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_buChar, XML_char, USS( OUString( aBulletChar ) ), FSEND ); 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir } 1032cdf0e10cSrcweir } 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir } 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir 1037cdf0e10cSrcweir const char* DrawingML::GetAlignment( sal_Int32 nAlignment ) 1038cdf0e10cSrcweir { 1039cdf0e10cSrcweir const char* sAlignment = NULL; 1040cdf0e10cSrcweir 1041cdf0e10cSrcweir switch( nAlignment ) { 1042cdf0e10cSrcweir case style::ParagraphAdjust_CENTER: 1043cdf0e10cSrcweir sAlignment = "ctr"; 1044cdf0e10cSrcweir break; 1045cdf0e10cSrcweir case style::ParagraphAdjust_RIGHT: 1046cdf0e10cSrcweir sAlignment = "r"; 1047cdf0e10cSrcweir break; 1048cdf0e10cSrcweir case style::ParagraphAdjust_BLOCK: 1049cdf0e10cSrcweir sAlignment = "just"; 1050cdf0e10cSrcweir break; 1051cdf0e10cSrcweir default: 1052cdf0e10cSrcweir ; 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir return sAlignment; 1056cdf0e10cSrcweir } 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir void DrawingML::WriteParagraphProperties( Reference< XTextContent > rParagraph ) 1059cdf0e10cSrcweir { 1060cdf0e10cSrcweir Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY ); 1061cdf0e10cSrcweir Reference< XPropertyState > rXPropState( rParagraph, UNO_QUERY ); 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir if( !rXPropSet.is() || !rXPropState.is() ) 1064cdf0e10cSrcweir return; 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir sal_Int16 nLevel = -1; 1067cdf0e10cSrcweir GET( nLevel, NumberingLevel ); 1068cdf0e10cSrcweir 1069cdf0e10cSrcweir sal_Int32 nLeftMargin = 0; 1070cdf0e10cSrcweir // fix coordinates 1071cdf0e10cSrcweir //GET( nLeftMargin, ParaLeftMargin ); 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir sal_Int16 nAlignment( style::ParagraphAdjust_LEFT ); 1074cdf0e10cSrcweir GET( nAlignment, ParaAdjust ); 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir if( nLevel != -1 1077cdf0e10cSrcweir || nLeftMargin > 0 1078cdf0e10cSrcweir || nAlignment != style::ParagraphAdjust_LEFT ) { 1079cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_pPr, 1080cdf0e10cSrcweir XML_lvl, nLevel > 0 ? I32S( nLevel ) : NULL, 1081cdf0e10cSrcweir XML_marL, nLeftMargin > 0 ? IS( nLeftMargin ) : NULL, 1082cdf0e10cSrcweir XML_algn, GetAlignment( nAlignment ), 1083cdf0e10cSrcweir FSEND ); 1084cdf0e10cSrcweir 1085cdf0e10cSrcweir WriteParagraphNumbering( rXPropSet, nLevel ); 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_pPr ); 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir } 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph ) 1092cdf0e10cSrcweir { 1093cdf0e10cSrcweir Reference< XEnumerationAccess > access( rParagraph, UNO_QUERY ); 1094cdf0e10cSrcweir if( !access.is() ) 1095cdf0e10cSrcweir return; 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir Reference< XEnumeration > enumeration( access->createEnumeration() ); 1098cdf0e10cSrcweir if( !enumeration.is() ) 1099cdf0e10cSrcweir return; 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_p, FSEND ); 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir sal_Bool bPropertiesWritten = FALSE; 1104cdf0e10cSrcweir while( enumeration->hasMoreElements() ) { 1105cdf0e10cSrcweir Reference< XTextRange > run; 1106cdf0e10cSrcweir Any any ( enumeration->nextElement() ); 1107cdf0e10cSrcweir 1108cdf0e10cSrcweir if (any >>= run) { 1109cdf0e10cSrcweir if( !bPropertiesWritten && run->getString().getLength() ) { 1110cdf0e10cSrcweir WriteParagraphProperties( rParagraph ); 1111cdf0e10cSrcweir bPropertiesWritten = TRUE; 1112cdf0e10cSrcweir } 1113cdf0e10cSrcweir WriteRun( run ); 1114cdf0e10cSrcweir } 1115cdf0e10cSrcweir } 1116cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_endParaRPr, FSEND ); 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_p ); 1119cdf0e10cSrcweir } 1120cdf0e10cSrcweir 1121cdf0e10cSrcweir void DrawingML::WriteText( Reference< XShape > rXShape ) 1122cdf0e10cSrcweir { 1123cdf0e10cSrcweir Reference< XText > xXText( rXShape, UNO_QUERY ); 1124cdf0e10cSrcweir Reference< XPropertySet > rXPropSet( rXShape, UNO_QUERY ); 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir if( !xXText.is() ) 1127cdf0e10cSrcweir return; 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir #define DEFLRINS 254 1130cdf0e10cSrcweir #define DEFTBINS 127 1131cdf0e10cSrcweir sal_Int32 nLeft, nRight, nTop, nBottom; 1132cdf0e10cSrcweir nLeft = nRight = DEFLRINS; 1133cdf0e10cSrcweir nTop = nBottom = DEFTBINS; 1134cdf0e10cSrcweir 1135cdf0e10cSrcweir // top inset looks a bit different compared to ppt export 1136cdf0e10cSrcweir // check if something related doesn't work as expected 1137cdf0e10cSrcweir GET( nLeft, TextLeftDistance ); 1138cdf0e10cSrcweir GET( nRight, TextRightDistance ); 1139cdf0e10cSrcweir GET( nTop, TextUpperDistance ); 1140cdf0e10cSrcweir GET( nBottom, TextLowerDistance ); 1141cdf0e10cSrcweir 1142cdf0e10cSrcweir TextVerticalAdjust eVerticalAlignment( TextVerticalAdjust_TOP ); 1143cdf0e10cSrcweir const char* sVerticalAlignment = NULL; 1144cdf0e10cSrcweir GET( eVerticalAlignment, TextVerticalAdjust ); 1145cdf0e10cSrcweir switch( eVerticalAlignment ) { 1146cdf0e10cSrcweir case TextVerticalAdjust_BOTTOM: 1147cdf0e10cSrcweir sVerticalAlignment = "b"; 1148cdf0e10cSrcweir break; 1149cdf0e10cSrcweir case TextVerticalAdjust_CENTER: 1150cdf0e10cSrcweir sVerticalAlignment = "ctr"; 1151cdf0e10cSrcweir break; 1152cdf0e10cSrcweir case TextVerticalAdjust_TOP: 1153cdf0e10cSrcweir default: 1154cdf0e10cSrcweir ; 1155cdf0e10cSrcweir } 1156cdf0e10cSrcweir 1157cdf0e10cSrcweir TextHorizontalAdjust eHorizontalAlignment( TextHorizontalAdjust_CENTER ); 1158cdf0e10cSrcweir bool bHorizontalCenter = false; 1159cdf0e10cSrcweir GET( eHorizontalAlignment, TextHorizontalAdjust ); 1160cdf0e10cSrcweir if( eHorizontalAlignment == TextHorizontalAdjust_CENTER ) 1161cdf0e10cSrcweir bHorizontalCenter = true; 1162cdf0e10cSrcweir 1163cdf0e10cSrcweir sal_Bool bHasWrap = FALSE; 1164cdf0e10cSrcweir sal_Bool bWrap = FALSE; 1165cdf0e10cSrcweir if( GETA( TextWordWrap ) ) { 1166cdf0e10cSrcweir mAny >>= bWrap; 1167cdf0e10cSrcweir bHasWrap = TRUE; 1168cdf0e10cSrcweir //DBG(printf("wrap: %d\n", bWrap)); 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_bodyPr, 1172cdf0e10cSrcweir XML_wrap, bHasWrap && !bWrap ? "none" : NULL, 1173cdf0e10cSrcweir XML_lIns, (nLeft != DEFLRINS) ? IS( MM100toEMU( nLeft ) ) : NULL, 1174cdf0e10cSrcweir XML_rIns, (nRight != DEFLRINS) ? IS( MM100toEMU( nRight ) ) : NULL, 1175cdf0e10cSrcweir XML_tIns, (nTop != DEFTBINS) ? IS( MM100toEMU( nTop ) ) : NULL, 1176cdf0e10cSrcweir XML_bIns, (nBottom != DEFTBINS) ? IS( MM100toEMU( nBottom ) ) : NULL, 1177cdf0e10cSrcweir XML_anchor, sVerticalAlignment, 1178cdf0e10cSrcweir XML_anchorCtr, bHorizontalCenter ? "1" : NULL, 1179cdf0e10cSrcweir FSEND ); 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir Reference< XEnumerationAccess > access( xXText, UNO_QUERY ); 1182cdf0e10cSrcweir if( !access.is() ) 1183cdf0e10cSrcweir return; 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir Reference< XEnumeration > enumeration( access->createEnumeration() ); 1186cdf0e10cSrcweir if( !enumeration.is() ) 1187cdf0e10cSrcweir return; 1188cdf0e10cSrcweir 1189cdf0e10cSrcweir while( enumeration->hasMoreElements() ) { 1190cdf0e10cSrcweir Reference< XTextContent > paragraph; 1191cdf0e10cSrcweir Any any ( enumeration->nextElement() ); 1192cdf0e10cSrcweir 1193cdf0e10cSrcweir if( any >>= paragraph) 1194cdf0e10cSrcweir WriteParagraph( paragraph ); 1195cdf0e10cSrcweir } 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir } 1198cdf0e10cSrcweir 1199cdf0e10cSrcweir void DrawingML::WritePresetShape( const char* pShape ) 1200cdf0e10cSrcweir { 1201cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_prstGeom, 1202cdf0e10cSrcweir XML_prst, pShape, 1203cdf0e10cSrcweir FSEND ); 1204cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_avLst, FSEND ); 1205cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_prstGeom ); 1206cdf0e10cSrcweir } 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const PropertyValue& rProp ) 1209cdf0e10cSrcweir { 1210cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_prstGeom, 1211cdf0e10cSrcweir XML_prst, pShape, 1212cdf0e10cSrcweir FSEND ); 1213cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_avLst, FSEND ); 1214cdf0e10cSrcweir 1215cdf0e10cSrcweir Sequence< drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq; 1216cdf0e10cSrcweir if ( rProp.Value >>= aAdjustmentSeq ) { 1217cdf0e10cSrcweir DBG(printf("adj seq len: %d\n", int( aAdjustmentSeq.getLength() ))); 1218cdf0e10cSrcweir if ( bPredefinedHandlesUsed ) 1219cdf0e10cSrcweir EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted ); 1220cdf0e10cSrcweir 1221cdf0e10cSrcweir sal_Int32 nValue, nLength = aAdjustmentSeq.getLength(); 1222cdf0e10cSrcweir for( sal_Int32 i=0; i < nLength; i++ ) 1223cdf0e10cSrcweir if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) ) 1224cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_gd, 1225cdf0e10cSrcweir XML_name, nLength > 1 ? ( OString( "adj" ) + OString::valueOf( i + 1 ) ).getStr() : "adj", 1226cdf0e10cSrcweir XML_fmla, (OString("val ") + OString::valueOf( nValue )).getStr(), 1227cdf0e10cSrcweir FSEND ); 1228cdf0e10cSrcweir } 1229cdf0e10cSrcweir 1230cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_avLst ); 1231cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_prstGeom ); 1232cdf0e10cSrcweir } 1233cdf0e10cSrcweir 1234cdf0e10cSrcweir void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) 1235cdf0e10cSrcweir { 1236cdf0e10cSrcweir if( rPolyPolygon.Count() < 1 ) 1237cdf0e10cSrcweir return; 1238cdf0e10cSrcweir 1239cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_custGeom, FSEND ); 1240cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_avLst, FSEND ); 1241cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_gdLst, FSEND ); 1242cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_ahLst, FSEND ); 1243cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_rect, 1244cdf0e10cSrcweir XML_l, "0", 1245cdf0e10cSrcweir XML_t, "0", 1246cdf0e10cSrcweir XML_r, "r", 1247cdf0e10cSrcweir XML_b, "b", 1248cdf0e10cSrcweir FSEND ); 1249cdf0e10cSrcweir 1250cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_pathLst, FSEND ); 1251cdf0e10cSrcweir 1252cdf0e10cSrcweir for( USHORT i = 0; i < rPolyPolygon.Count(); i ++ ) { 1253cdf0e10cSrcweir 1254cdf0e10cSrcweir const Polygon& rPoly = rPolyPolygon[ i ]; 1255cdf0e10cSrcweir Rectangle aRect( rPoly.GetBoundRect() ); 1256cdf0e10cSrcweir sal_Bool bBezier = FALSE; 1257cdf0e10cSrcweir 1258cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_path, 1259cdf0e10cSrcweir XML_w, I64S( aRect.GetWidth() ), 1260cdf0e10cSrcweir XML_h, I64S( aRect.GetHeight() ), 1261cdf0e10cSrcweir FSEND ); 1262cdf0e10cSrcweir 1263cdf0e10cSrcweir if( rPoly.GetSize() > 0 ) 1264cdf0e10cSrcweir { 1265cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_moveTo, FSEND ); 1266cdf0e10cSrcweir 1267cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_pt, 1268cdf0e10cSrcweir XML_x, I64S( rPoly[ 0 ].X() - aRect.Left() ), 1269cdf0e10cSrcweir XML_y, I64S( rPoly[ 0 ].Y() - aRect.Top() ), 1270cdf0e10cSrcweir FSEND ); 1271cdf0e10cSrcweir 1272cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_moveTo ); 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir for( USHORT j = 1; j < rPoly.GetSize(); j ++ ) 1276cdf0e10cSrcweir { 1277cdf0e10cSrcweir enum PolyFlags flags = rPoly.GetFlags(j); 1278cdf0e10cSrcweir if( flags == POLY_CONTROL && !bBezier ) 1279cdf0e10cSrcweir { 1280cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND ); 1281cdf0e10cSrcweir bBezier = TRUE; 1282cdf0e10cSrcweir } 1283cdf0e10cSrcweir else if( flags == POLY_NORMAL && !bBezier ) 1284cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_lnTo, FSEND ); 1285cdf0e10cSrcweir 1286cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_pt, 1287cdf0e10cSrcweir XML_x, I64S( rPoly[j].X() - aRect.Left() ), 1288cdf0e10cSrcweir XML_y, I64S( rPoly[j].Y() - aRect.Top() ), 1289cdf0e10cSrcweir FSEND ); 1290cdf0e10cSrcweir 1291cdf0e10cSrcweir if( ( flags == POLY_NORMAL || flags == POLY_SYMMTR ) && bBezier ) 1292cdf0e10cSrcweir { 1293cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_cubicBezTo ); 1294cdf0e10cSrcweir bBezier = FALSE; 1295cdf0e10cSrcweir } 1296cdf0e10cSrcweir else if( flags == POLY_NORMAL && !bBezier ) 1297cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_lnTo ); 1298cdf0e10cSrcweir else if( bBezier && ( j % 3 ) == 0 ) 1299cdf0e10cSrcweir { 1300cdf0e10cSrcweir // //a:cubicBezTo can only contain 3 //a:pt elements, so we 1301cdf0e10cSrcweir // need to break things up... 1302cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_cubicBezTo ); 1303cdf0e10cSrcweir mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND ); 1304cdf0e10cSrcweir } 1305cdf0e10cSrcweir // switch( rPoly.GetFlags(j) ) { 1306cdf0e10cSrcweir // case POLY_NORMAL: 1307cdf0e10cSrcweir // DBG(printf("normal\n")); 1308cdf0e10cSrcweir // break; 1309cdf0e10cSrcweir // case POLY_SMOOTH: 1310cdf0e10cSrcweir // DBG(printf("smooth\n")); 1311cdf0e10cSrcweir // break; 1312cdf0e10cSrcweir // case POLY_CONTROL: 1313cdf0e10cSrcweir // DBG(printf("control\n")); 1314cdf0e10cSrcweir // break; 1315cdf0e10cSrcweir // case POLY_SYMMTR: 1316cdf0e10cSrcweir // DBG(printf("symmtr\n")); 1317cdf0e10cSrcweir // break; 1318cdf0e10cSrcweir // } 1319cdf0e10cSrcweir // DBG(printf("point %ld %ld\n", rPoly[j].X() - aRect.Left(), rPoly[j].Y() - aRect.Top())); 1320cdf0e10cSrcweir } 1321cdf0e10cSrcweir 1322cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_path ); 1323cdf0e10cSrcweir } 1324cdf0e10cSrcweir 1325cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_pathLst ); 1326cdf0e10cSrcweir 1327cdf0e10cSrcweir mpFS->endElementNS( XML_a, XML_custGeom ); 1328cdf0e10cSrcweir } 1329cdf0e10cSrcweir 1330cdf0e10cSrcweir void DrawingML::WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID ) 1331cdf0e10cSrcweir { 1332cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_stCxn, 1333cdf0e10cSrcweir XML_id, I32S( nStartID ), 1334cdf0e10cSrcweir XML_idx, I64S( rConnectorEntry.GetConnectorRule( TRUE ) ), 1335cdf0e10cSrcweir FSEND ); 1336cdf0e10cSrcweir mpFS->singleElementNS( XML_a, XML_endCxn, 1337cdf0e10cSrcweir XML_id, I32S( nEndID ), 1338cdf0e10cSrcweir XML_idx, I64S( rConnectorEntry.GetConnectorRule( FALSE ) ), 1339cdf0e10cSrcweir FSEND ); 1340cdf0e10cSrcweir } 1341cdf0e10cSrcweir 1342cdf0e10cSrcweir // from sw/source/filter/ww8/wrtw8num.cxx for default bullets to export to MS intact 1343cdf0e10cSrcweir static void lcl_SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, String& rFontName) 1344cdf0e10cSrcweir { 1345cdf0e10cSrcweir sal_Unicode cChar = rNumStr.GetChar(0); 1346cdf0e10cSrcweir StarSymbolToMSMultiFont *pConvert = CreateStarSymbolToMSMultiFont(); 1347cdf0e10cSrcweir String sFont = pConvert->ConvertChar(cChar); 1348cdf0e10cSrcweir delete pConvert; 1349cdf0e10cSrcweir if (sFont.Len()) 1350cdf0e10cSrcweir { 1351cdf0e10cSrcweir rNumStr = static_cast< sal_Unicode >(cChar | 0xF000); 1352cdf0e10cSrcweir rFontName = sFont; 1353cdf0e10cSrcweir rChrSet = RTL_TEXTENCODING_SYMBOL; 1354cdf0e10cSrcweir } 1355cdf0e10cSrcweir else if ( (rNumStr.GetChar(0) < 0xE000 || rNumStr.GetChar(0) > 0xF8FF) ) 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir /* 1358cdf0e10cSrcweir Ok we can't fit into a known windows unicode font, but 1359cdf0e10cSrcweir we are not in the private area, so we are a 1360cdf0e10cSrcweir standardized symbol, so turn off the symbol bit and 1361cdf0e10cSrcweir let words own font substitution kick in 1362cdf0e10cSrcweir */ 1363cdf0e10cSrcweir rChrSet = RTL_TEXTENCODING_UNICODE; 1364cdf0e10cSrcweir rFontName = ::GetFontToken(rFontName, 0); 1365cdf0e10cSrcweir } 1366cdf0e10cSrcweir else 1367cdf0e10cSrcweir { 1368cdf0e10cSrcweir /* 1369*d941b70cSJohn Bampton Well we don't have an available substitution, and we're 1370cdf0e10cSrcweir in our private area, so give up and show a standard 1371cdf0e10cSrcweir bullet symbol 1372cdf0e10cSrcweir */ 1373cdf0e10cSrcweir rFontName.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Wingdings")); 1374cdf0e10cSrcweir rNumStr = static_cast< sal_Unicode >(0x6C); 1375cdf0e10cSrcweir } 1376cdf0e10cSrcweir } 1377cdf0e10cSrcweir 1378cdf0e10cSrcweir sal_Unicode DrawingML::SubstituteBullet( sal_Unicode cBulletId, ::com::sun::star::awt::FontDescriptor& rFontDesc ) 1379cdf0e10cSrcweir { 1380cdf0e10cSrcweir String sNumStr = cBulletId; 1381cdf0e10cSrcweir 1382cdf0e10cSrcweir if ( rFontDesc.Name.equalsIgnoreAsciiCaseAscii("starsymbol") || 1383cdf0e10cSrcweir rFontDesc.Name.equalsIgnoreAsciiCaseAscii("opensymbol") ) { 1384cdf0e10cSrcweir String sFontName = rFontDesc.Name; 1385cdf0e10cSrcweir rtl_TextEncoding aCharSet = rFontDesc.CharSet; 1386cdf0e10cSrcweir 1387cdf0e10cSrcweir lcl_SubstituteBullet( sNumStr, aCharSet, sFontName ); 1388cdf0e10cSrcweir 1389cdf0e10cSrcweir rFontDesc.Name = sFontName; 1390cdf0e10cSrcweir rFontDesc.CharSet = aCharSet; 1391cdf0e10cSrcweir } 1392cdf0e10cSrcweir 1393cdf0e10cSrcweir return sNumStr.GetChar( 0 ); 1394cdf0e10cSrcweir } 1395cdf0e10cSrcweir 1396cdf0e10cSrcweir } 1397cdf0e10cSrcweir } 1398