1*d0626817SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d0626817SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d0626817SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d0626817SAndrew Rist * distributed with this work for additional information 6*d0626817SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d0626817SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d0626817SAndrew Rist * "License"); you may not use this file except in compliance 9*d0626817SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*d0626817SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*d0626817SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d0626817SAndrew Rist * software distributed under the License is distributed on an 15*d0626817SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d0626817SAndrew Rist * KIND, either express or implied. See the License for the 17*d0626817SAndrew Rist * specific language governing permissions and limitations 18*d0626817SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*d0626817SAndrew Rist *************************************************************/ 21*d0626817SAndrew Rist 22*d0626817SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "oox/xls/drawingmanager.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 27cdf0e10cSrcweir #include <com/sun/star/drawing/CircleKind.hpp> 28cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp> 29cdf0e10cSrcweir #include <com/sun/star/drawing/PolygonKind.hpp> 30cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 31cdf0e10cSrcweir #include "oox/core/filterbase.hxx" 32cdf0e10cSrcweir #include "oox/drawingml/fillproperties.hxx" 33cdf0e10cSrcweir #include "oox/drawingml/lineproperties.hxx" 34cdf0e10cSrcweir #include "oox/drawingml/shapepropertymap.hxx" 35cdf0e10cSrcweir #include "oox/helper/containerhelper.hxx" 36cdf0e10cSrcweir #include "oox/token/tokens.hxx" 37cdf0e10cSrcweir #include "oox/xls/biffinputstream.hxx" 38cdf0e10cSrcweir #include "oox/xls/unitconverter.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace oox { 41cdf0e10cSrcweir namespace xls { 42cdf0e10cSrcweir 43cdf0e10cSrcweir // ============================================================================ 44cdf0e10cSrcweir 45cdf0e10cSrcweir using namespace ::com::sun::star::awt; 46cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 47cdf0e10cSrcweir using namespace ::com::sun::star::lang; 48cdf0e10cSrcweir using namespace ::com::sun::star::uno; 49cdf0e10cSrcweir using namespace ::oox::drawingml; 50cdf0e10cSrcweir 51cdf0e10cSrcweir using ::rtl::OUString; 52cdf0e10cSrcweir 53cdf0e10cSrcweir // ============================================================================ 54cdf0e10cSrcweir 55cdf0e10cSrcweir namespace { 56cdf0e10cSrcweir 57cdf0e10cSrcweir // OBJ record ----------------------------------------------------------------- 58cdf0e10cSrcweir 59cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_GROUP = 0; 60cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_LINE = 1; 61cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_RECTANGLE = 2; 62cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_OVAL = 3; 63cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_ARC = 4; 64cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_CHART = 5; 65cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_TEXT = 6; 66cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_BUTTON = 7; 67cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_PICTURE = 8; 68cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_POLYGON = 9; // new in BIFF4 69cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_CHECKBOX = 11; // new in BIFF5 70cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_OPTIONBUTTON = 12; 71cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_EDIT = 13; 72cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_LABEL = 14; 73cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_DIALOG = 15; 74cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_SPIN = 16; 75cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_SCROLLBAR = 17; 76cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_LISTBOX = 18; 77cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_GROUPBOX = 19; 78cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_DROPDOWN = 20; 79cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_NOTE = 25; // new in BIFF8 80cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_DRAWING = 30; 81cdf0e10cSrcweir const sal_uInt16 BIFF_OBJTYPE_UNKNOWN = 0xFFFF; // for internal use only 82cdf0e10cSrcweir 83cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_HIDDEN = 0x0100; 84cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_VISIBLE = 0x0200; 85cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_PRINTABLE = 0x0400; 86cdf0e10cSrcweir 87cdf0e10cSrcweir // line formatting ------------------------------------------------------------ 88cdf0e10cSrcweir 89cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_AUTOCOLOR = 64; 90cdf0e10cSrcweir 91cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_SOLID = 0; 92cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_DASH = 1; 93cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_DOT = 2; 94cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_DASHDOT = 3; 95cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_DASHDOTDOT = 4; 96cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_MEDTRANS = 5; 97cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_DARKTRANS = 6; 98cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_LIGHTTRANS = 7; 99cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_NONE = 255; 100cdf0e10cSrcweir 101cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_HAIR = 0; 102cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_THIN = 1; 103cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_MEDIUM = 2; 104cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_THICK = 3; 105cdf0e10cSrcweir 106cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_AUTO = 0x01; 107cdf0e10cSrcweir 108cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_NONE = 0; 109cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_OPEN = 1; 110cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_FILLED = 2; 111cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_OPENBOTH = 3; 112cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_FILLEDBOTH = 4; 113cdf0e10cSrcweir 114cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_NARROW = 0; 115cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_MEDIUM = 1; 116cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARROW_WIDE = 2; 117cdf0e10cSrcweir 118cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_TL = 0; 119cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_TR = 1; 120cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_BR = 2; 121cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_LINE_BL = 3; 122cdf0e10cSrcweir 123cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARC_TR = 0; 124cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARC_TL = 1; 125cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARC_BL = 2; 126cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_ARC_BR = 3; 127cdf0e10cSrcweir 128cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_POLY_CLOSED = 0x0100; 129cdf0e10cSrcweir 130cdf0e10cSrcweir // fill formatting ------------------------------------------------------------ 131cdf0e10cSrcweir 132cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_FILL_AUTOCOLOR = 65; 133cdf0e10cSrcweir 134cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_PATT_NONE = 0; 135cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_PATT_SOLID = 1; 136cdf0e10cSrcweir 137cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_FILL_AUTO = 0x01; 138cdf0e10cSrcweir 139cdf0e10cSrcweir // text formatting ------------------------------------------------------------ 140cdf0e10cSrcweir 141cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_HOR_LEFT = 1; 142cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_HOR_CENTER = 2; 143cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_HOR_RIGHT = 3; 144cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_HOR_JUSTIFY = 4; 145cdf0e10cSrcweir 146cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_VER_TOP = 1; 147cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_VER_CENTER = 2; 148cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_VER_BOTTOM = 3; 149cdf0e10cSrcweir const sal_uInt8 BIFF_OBJ_VER_JUSTIFY = 4; 150cdf0e10cSrcweir 151cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_ORIENT_NONE = 0; 152cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_ORIENT_STACKED = 1; /// Stacked top to bottom. 153cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_ORIENT_90CCW = 2; /// 90 degr. counterclockwise. 154cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_ORIENT_90CW = 3; /// 90 degr. clockwise. 155cdf0e10cSrcweir 156cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_TEXT_AUTOSIZE = 0x0080; 157cdf0e10cSrcweir const sal_uInt16 BIFF_OBJ_TEXT_LOCKED = 0x0200; 158cdf0e10cSrcweir 159cdf0e10cSrcweir const sal_Int32 BIFF_OBJ_TEXT_MARGIN = 20000; /// Automatic text margin (EMUs). 160cdf0e10cSrcweir 161cdf0e10cSrcweir // BIFF8 OBJ sub records ------------------------------------------------------ 162cdf0e10cSrcweir 163cdf0e10cSrcweir const sal_uInt16 BIFF_OBJCMO_PRINTABLE = 0x0010; /// Object printable. 164cdf0e10cSrcweir const sal_uInt16 BIFF_OBJCMO_AUTOLINE = 0x2000; /// Automatic line formatting. 165cdf0e10cSrcweir const sal_uInt16 BIFF_OBJCMO_AUTOFILL = 0x4000; /// Automatic fill formatting. 166cdf0e10cSrcweir 167cdf0e10cSrcweir // ---------------------------------------------------------------------------- 168cdf0e10cSrcweir 169cdf0e10cSrcweir inline BiffInputStream& operator>>( BiffInputStream& rStrm, ShapeAnchor& rAnchor ) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir rAnchor.importBiffAnchor( rStrm ); 172cdf0e10cSrcweir return rStrm; 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir } // namespace 176cdf0e10cSrcweir 177cdf0e10cSrcweir // ============================================================================ 178cdf0e10cSrcweir // Model structures for BIFF OBJ record data 179cdf0e10cSrcweir // ============================================================================ 180cdf0e10cSrcweir 181cdf0e10cSrcweir BiffObjLineModel::BiffObjLineModel() : 182cdf0e10cSrcweir mnColorIdx( BIFF_OBJ_LINE_AUTOCOLOR ), 183cdf0e10cSrcweir mnStyle( BIFF_OBJ_LINE_SOLID ), 184cdf0e10cSrcweir mnWidth( BIFF_OBJ_LINE_HAIR ), 185cdf0e10cSrcweir mbAuto( true ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir bool BiffObjLineModel::isVisible() const 190cdf0e10cSrcweir { 191cdf0e10cSrcweir return mbAuto || (mnStyle != BIFF_OBJ_LINE_NONE); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir BiffInputStream& operator>>( BiffInputStream& rStrm, BiffObjLineModel& rModel ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir sal_uInt8 nFlags; 197cdf0e10cSrcweir rStrm >> rModel.mnColorIdx >> rModel.mnStyle >> rModel.mnWidth >> nFlags; 198cdf0e10cSrcweir rModel.mbAuto = getFlag( nFlags, BIFF_OBJ_LINE_AUTO ); 199cdf0e10cSrcweir return rStrm; 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir // ============================================================================ 203cdf0e10cSrcweir 204cdf0e10cSrcweir BiffObjFillModel::BiffObjFillModel() : 205cdf0e10cSrcweir mnBackColorIdx( BIFF_OBJ_LINE_AUTOCOLOR ), 206cdf0e10cSrcweir mnPattColorIdx( BIFF_OBJ_FILL_AUTOCOLOR ), 207cdf0e10cSrcweir mnPattern( BIFF_OBJ_PATT_SOLID ), 208cdf0e10cSrcweir mbAuto( true ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir bool BiffObjFillModel::isFilled() const 213cdf0e10cSrcweir { 214cdf0e10cSrcweir return mbAuto || (mnPattern != BIFF_OBJ_PATT_NONE); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir BiffInputStream& operator>>( BiffInputStream& rStrm, BiffObjFillModel& rModel ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir sal_uInt8 nFlags; 220cdf0e10cSrcweir rStrm >> rModel.mnBackColorIdx >> rModel.mnPattColorIdx >> rModel.mnPattern >> nFlags; 221cdf0e10cSrcweir rModel.mbAuto = getFlag( nFlags, BIFF_OBJ_FILL_AUTO ); 222cdf0e10cSrcweir return rStrm; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir // ============================================================================ 226cdf0e10cSrcweir 227cdf0e10cSrcweir BiffObjTextModel::BiffObjTextModel() : 228cdf0e10cSrcweir mnTextLen( 0 ), 229cdf0e10cSrcweir mnFormatSize( 0 ), 230cdf0e10cSrcweir mnLinkSize( 0 ), 231cdf0e10cSrcweir mnDefFontId( 0 ), 232cdf0e10cSrcweir mnFlags( 0 ), 233cdf0e10cSrcweir mnOrientation( BIFF_OBJ_ORIENT_NONE ), 234cdf0e10cSrcweir mnButtonFlags( 0 ), 235cdf0e10cSrcweir mnShortcut( 0 ), 236cdf0e10cSrcweir mnShortcutEA( 0 ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir void BiffObjTextModel::readObj3( BiffInputStream& rStrm ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir rStrm >> mnTextLen; 243cdf0e10cSrcweir rStrm.skip( 2 ); 244cdf0e10cSrcweir rStrm >> mnFormatSize >> mnDefFontId; 245cdf0e10cSrcweir rStrm.skip( 2 ); 246cdf0e10cSrcweir rStrm >> mnFlags >> mnOrientation; 247cdf0e10cSrcweir rStrm.skip( 8 ); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir void BiffObjTextModel::readObj5( BiffInputStream& rStrm ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir rStrm >> mnTextLen; 253cdf0e10cSrcweir rStrm.skip( 2 ); 254cdf0e10cSrcweir rStrm >> mnFormatSize >> mnDefFontId; 255cdf0e10cSrcweir rStrm.skip( 2 ); 256cdf0e10cSrcweir rStrm >> mnFlags >> mnOrientation; 257cdf0e10cSrcweir rStrm.skip( 2 ); 258cdf0e10cSrcweir rStrm >> mnLinkSize; 259cdf0e10cSrcweir rStrm.skip( 2 ); 260cdf0e10cSrcweir rStrm >> mnButtonFlags >> mnShortcut >> mnShortcutEA; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir void BiffObjTextModel::readTxo8( BiffInputStream& rStrm ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir rStrm >> mnFlags >> mnOrientation >> mnButtonFlags >> mnShortcut >> mnShortcutEA >> mnTextLen >> mnFormatSize; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir sal_uInt8 BiffObjTextModel::getHorAlign() const 269cdf0e10cSrcweir { 270cdf0e10cSrcweir return extractValue< sal_uInt8 >( mnFlags, 1, 3 ); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir sal_uInt8 BiffObjTextModel::getVerAlign() const 274cdf0e10cSrcweir { 275cdf0e10cSrcweir return extractValue< sal_uInt8 >( mnFlags, 4, 3 ); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir // ============================================================================ 279cdf0e10cSrcweir // BIFF drawing objects 280cdf0e10cSrcweir // ============================================================================ 281cdf0e10cSrcweir 282cdf0e10cSrcweir BiffDrawingObjectContainer::BiffDrawingObjectContainer() 283cdf0e10cSrcweir { 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir void BiffDrawingObjectContainer::append( const BiffDrawingObjectRef& rxDrawingObj ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir maObjects.push_back( rxDrawingObj ); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir void BiffDrawingObjectContainer::insertGrouped( const BiffDrawingObjectRef& rxDrawingObj ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir if( !maObjects.empty() ) 294cdf0e10cSrcweir if( BiffGroupObject* pGroupObj = dynamic_cast< BiffGroupObject* >( maObjects.back().get() ) ) 295cdf0e10cSrcweir if( pGroupObj->tryInsert( rxDrawingObj ) ) 296cdf0e10cSrcweir return; 297cdf0e10cSrcweir maObjects.push_back( rxDrawingObj ); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir void BiffDrawingObjectContainer::convertAndInsert( BiffDrawingBase& rDrawing, const Reference< XShapes >& rxShapes, const Rectangle* pParentRect ) const 301cdf0e10cSrcweir { 302cdf0e10cSrcweir maObjects.forEachMem( &BiffDrawingObjectBase::convertAndInsert, ::boost::ref( rDrawing ), ::boost::cref( rxShapes ), pParentRect ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir // ============================================================================ 306cdf0e10cSrcweir 307cdf0e10cSrcweir BiffDrawingObjectBase::BiffDrawingObjectBase( const WorksheetHelper& rHelper ) : 308cdf0e10cSrcweir WorksheetHelper( rHelper ), 309cdf0e10cSrcweir maAnchor( rHelper ), 310cdf0e10cSrcweir mnDffShapeId( 0 ), 311cdf0e10cSrcweir mnDffFlags( 0 ), 312cdf0e10cSrcweir mnObjId( BIFF_OBJ_INVALID_ID ), 313cdf0e10cSrcweir mnObjType( BIFF_OBJTYPE_UNKNOWN ), 314cdf0e10cSrcweir mbHasAnchor( false ), 315cdf0e10cSrcweir mbHidden( false ), 316cdf0e10cSrcweir mbVisible( true ), 317cdf0e10cSrcweir mbPrintable( true ), 318cdf0e10cSrcweir mbAreaObj( false ), 319cdf0e10cSrcweir mbAutoMargin( true ), 320cdf0e10cSrcweir mbSimpleMacro( true ), 321cdf0e10cSrcweir mbProcessShape( true ), 322cdf0e10cSrcweir mbInsertShape( true ), 323cdf0e10cSrcweir mbCustomDff( false ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir BiffDrawingObjectBase::~BiffDrawingObjectBase() 328cdf0e10cSrcweir { 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir /*static*/ BiffDrawingObjectRef BiffDrawingObjectBase::importObjBiff3( const WorksheetHelper& rHelper, BiffInputStream& rStrm ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir BiffDrawingObjectRef xDrawingObj; 334cdf0e10cSrcweir 335cdf0e10cSrcweir if( rStrm.getRemaining() >= 30 ) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir sal_uInt16 nObjType; 338cdf0e10cSrcweir rStrm.skip( 4 ); 339cdf0e10cSrcweir rStrm >> nObjType; 340cdf0e10cSrcweir switch( nObjType ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir case BIFF_OBJTYPE_GROUP: xDrawingObj.reset( new BiffGroupObject( rHelper ) ); break; 343cdf0e10cSrcweir case BIFF_OBJTYPE_LINE: xDrawingObj.reset( new BiffLineObject( rHelper ) ); break; 344cdf0e10cSrcweir case BIFF_OBJTYPE_RECTANGLE: xDrawingObj.reset( new BiffRectObject( rHelper ) ); break; 345cdf0e10cSrcweir case BIFF_OBJTYPE_OVAL: xDrawingObj.reset( new BiffOvalObject( rHelper ) ); break; 346cdf0e10cSrcweir case BIFF_OBJTYPE_ARC: xDrawingObj.reset( new BiffArcObject( rHelper ) ); break; 347cdf0e10cSrcweir #if 0 348cdf0e10cSrcweir case BIFF_OBJTYPE_CHART: xDrawingObj.reset( new XclImpChartObj( rHelper ) ); break; 349cdf0e10cSrcweir case BIFF_OBJTYPE_TEXT: xDrawingObj.reset( new XclImpTextObj( rHelper ) ); break; 350cdf0e10cSrcweir case BIFF_OBJTYPE_BUTTON: xDrawingObj.reset( new XclImpButtonObj( rHelper ) ); break; 351cdf0e10cSrcweir case BIFF_OBJTYPE_PICTURE: xDrawingObj.reset( new XclImpPictureObj( rHelper ) ); break; 352cdf0e10cSrcweir #endif 353cdf0e10cSrcweir default: 354cdf0e10cSrcweir #if 0 355cdf0e10cSrcweir OSL_ENSURE( false, "BiffDrawingObjectBase::importObjBiff3 - unknown object type" ); 356cdf0e10cSrcweir #endif 357cdf0e10cSrcweir xDrawingObj.reset( new BiffPlaceholderObject( rHelper ) ); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir xDrawingObj->importObjBiff3( rStrm ); 362cdf0e10cSrcweir return xDrawingObj; 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir /*static*/ BiffDrawingObjectRef BiffDrawingObjectBase::importObjBiff4( const WorksheetHelper& rHelper, BiffInputStream& rStrm ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir BiffDrawingObjectRef xDrawingObj; 368cdf0e10cSrcweir 369cdf0e10cSrcweir if( rStrm.getRemaining() >= 30 ) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir sal_uInt16 nObjType; 372cdf0e10cSrcweir rStrm.skip( 4 ); 373cdf0e10cSrcweir rStrm >> nObjType; 374cdf0e10cSrcweir switch( nObjType ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir case BIFF_OBJTYPE_GROUP: xDrawingObj.reset( new BiffGroupObject( rHelper ) ); break; 377cdf0e10cSrcweir case BIFF_OBJTYPE_LINE: xDrawingObj.reset( new BiffLineObject( rHelper ) ); break; 378cdf0e10cSrcweir case BIFF_OBJTYPE_RECTANGLE: xDrawingObj.reset( new BiffRectObject( rHelper ) ); break; 379cdf0e10cSrcweir case BIFF_OBJTYPE_OVAL: xDrawingObj.reset( new BiffOvalObject( rHelper ) ); break; 380cdf0e10cSrcweir case BIFF_OBJTYPE_ARC: xDrawingObj.reset( new BiffArcObject( rHelper ) ); break; 381cdf0e10cSrcweir case BIFF_OBJTYPE_POLYGON: xDrawingObj.reset( new BiffPolygonObject( rHelper ) ); break; 382cdf0e10cSrcweir #if 0 383cdf0e10cSrcweir case BIFF_OBJTYPE_CHART: xDrawingObj.reset( new XclImpChartObj( rHelper ) ); break; 384cdf0e10cSrcweir case BIFF_OBJTYPE_TEXT: xDrawingObj.reset( new XclImpTextObj( rHelper ) ); break; 385cdf0e10cSrcweir case BIFF_OBJTYPE_BUTTON: xDrawingObj.reset( new XclImpButtonObj( rHelper ) ); break; 386cdf0e10cSrcweir case BIFF_OBJTYPE_PICTURE: xDrawingObj.reset( new XclImpPictureObj( rHelper ) ); break; 387cdf0e10cSrcweir #endif 388cdf0e10cSrcweir default: 389cdf0e10cSrcweir #if 0 390cdf0e10cSrcweir OSL_ENSURE( false, "BiffDrawingObjectBase::importObjBiff4 - unknown object type" ); 391cdf0e10cSrcweir #endif 392cdf0e10cSrcweir xDrawingObj.reset( new BiffPlaceholderObject( rHelper ) ); 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir 396cdf0e10cSrcweir xDrawingObj->importObjBiff4( rStrm ); 397cdf0e10cSrcweir return xDrawingObj; 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir /*static*/ BiffDrawingObjectRef BiffDrawingObjectBase::importObjBiff5( const WorksheetHelper& rHelper, BiffInputStream& rStrm ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir BiffDrawingObjectRef xDrawingObj; 403cdf0e10cSrcweir 404cdf0e10cSrcweir if( rStrm.getRemaining() >= 34 ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir sal_uInt16 nObjType; 407cdf0e10cSrcweir rStrm.skip( 4 ); 408cdf0e10cSrcweir rStrm >> nObjType; 409cdf0e10cSrcweir switch( nObjType ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir case BIFF_OBJTYPE_GROUP: xDrawingObj.reset( new BiffGroupObject( rHelper ) ); break; 412cdf0e10cSrcweir case BIFF_OBJTYPE_LINE: xDrawingObj.reset( new BiffLineObject( rHelper ) ); break; 413cdf0e10cSrcweir case BIFF_OBJTYPE_RECTANGLE: xDrawingObj.reset( new BiffRectObject( rHelper ) ); break; 414cdf0e10cSrcweir case BIFF_OBJTYPE_OVAL: xDrawingObj.reset( new BiffOvalObject( rHelper ) ); break; 415cdf0e10cSrcweir case BIFF_OBJTYPE_ARC: xDrawingObj.reset( new BiffArcObject( rHelper ) ); break; 416cdf0e10cSrcweir case BIFF_OBJTYPE_POLYGON: xDrawingObj.reset( new BiffPolygonObject( rHelper ) ); break; 417cdf0e10cSrcweir #if 0 418cdf0e10cSrcweir case BIFF_OBJTYPE_CHART: xDrawingObj.reset( new XclImpChartObj( rHelper ) ); break; 419cdf0e10cSrcweir case BIFF_OBJTYPE_TEXT: xDrawingObj.reset( new XclImpTextObj( rHelper ) ); break; 420cdf0e10cSrcweir case BIFF_OBJTYPE_BUTTON: xDrawingObj.reset( new XclImpButtonObj( rHelper ) ); break; 421cdf0e10cSrcweir case BIFF_OBJTYPE_PICTURE: xDrawingObj.reset( new XclImpPictureObj( rHelper ) ); break; 422cdf0e10cSrcweir case BIFF_OBJTYPE_CHECKBOX: xDrawingObj.reset( new XclImpCheckBoxObj( rHelper ) ); break; 423cdf0e10cSrcweir case BIFF_OBJTYPE_OPTIONBUTTON: xDrawingObj.reset( new XclImpOptionButtonObj( rHelper ) ); break; 424cdf0e10cSrcweir case BIFF_OBJTYPE_EDIT: xDrawingObj.reset( new XclImpEditObj( rHelper ) ); break; 425cdf0e10cSrcweir case BIFF_OBJTYPE_LABEL: xDrawingObj.reset( new XclImpLabelObj( rHelper ) ); break; 426cdf0e10cSrcweir case BIFF_OBJTYPE_DIALOG: xDrawingObj.reset( new XclImpDialogObj( rHelper ) ); break; 427cdf0e10cSrcweir case BIFF_OBJTYPE_SPIN: xDrawingObj.reset( new XclImpSpinButtonObj( rHelper ) ); break; 428cdf0e10cSrcweir case BIFF_OBJTYPE_SCROLLBAR: xDrawingObj.reset( new XclImpScrollBarObj( rHelper ) ); break; 429cdf0e10cSrcweir case BIFF_OBJTYPE_LISTBOX: xDrawingObj.reset( new XclImpListBoxObj( rHelper ) ); break; 430cdf0e10cSrcweir case BIFF_OBJTYPE_GROUPBOX: xDrawingObj.reset( new XclImpGroupBoxObj( rHelper ) ); break; 431cdf0e10cSrcweir case BIFF_OBJTYPE_DROPDOWN: xDrawingObj.reset( new XclImpDropDownObj( rHelper ) ); break; 432cdf0e10cSrcweir #endif 433cdf0e10cSrcweir default: 434cdf0e10cSrcweir #if 0 435cdf0e10cSrcweir OSL_ENSURE( false, "BiffDrawingObjectBase::importObjBiff5 - unknown object type" ); 436cdf0e10cSrcweir #endif 437cdf0e10cSrcweir xDrawingObj.reset( new BiffPlaceholderObject( rHelper ) ); 438cdf0e10cSrcweir } 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir xDrawingObj->importObjBiff5( rStrm ); 442cdf0e10cSrcweir return xDrawingObj; 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir /*static*/ BiffDrawingObjectRef BiffDrawingObjectBase::importObjBiff8( const WorksheetHelper& rHelper, BiffInputStream& rStrm ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir BiffDrawingObjectRef xDrawingObj; 448cdf0e10cSrcweir 449cdf0e10cSrcweir if( rStrm.getRemaining() >= 10 ) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir sal_uInt16 nSubRecId, nSubRecSize, nObjType; 452cdf0e10cSrcweir rStrm >> nSubRecId >> nSubRecSize >> nObjType; 453cdf0e10cSrcweir OSL_ENSURE( nSubRecId == BIFF_ID_OBJCMO, "BiffDrawingObjectBase::importObjBiff8 - OBJCMO subrecord expected" ); 454cdf0e10cSrcweir if( (nSubRecId == BIFF_ID_OBJCMO) && (nSubRecSize >= 6) ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir switch( nObjType ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir #if 0 459cdf0e10cSrcweir // in BIFF8, all simple objects support text 460cdf0e10cSrcweir case BIFF_OBJTYPE_LINE: 461cdf0e10cSrcweir case BIFF_OBJTYPE_ARC: 462cdf0e10cSrcweir xDrawingObj.reset( new XclImpTextObj( rHelper ) ); 463cdf0e10cSrcweir // lines and arcs may be 2-dimensional 464cdf0e10cSrcweir xDrawingObj->setAreaObj( false ); 465cdf0e10cSrcweir break; 466cdf0e10cSrcweir 467cdf0e10cSrcweir // in BIFF8, all simple objects support text 468cdf0e10cSrcweir case BIFF_OBJTYPE_RECTANGLE: 469cdf0e10cSrcweir case BIFF_OBJTYPE_OVAL: 470cdf0e10cSrcweir case BIFF_OBJTYPE_POLYGON: 471cdf0e10cSrcweir case BIFF_OBJTYPE_DRAWING: 472cdf0e10cSrcweir case BIFF_OBJTYPE_TEXT: 473cdf0e10cSrcweir xDrawingObj.reset( new XclImpTextObj( rHelper ) ); 474cdf0e10cSrcweir break; 475cdf0e10cSrcweir #endif 476cdf0e10cSrcweir 477cdf0e10cSrcweir case BIFF_OBJTYPE_GROUP: xDrawingObj.reset( new BiffGroupObject( rHelper ) ); break; 478cdf0e10cSrcweir #if 0 479cdf0e10cSrcweir case BIFF_OBJTYPE_CHART: xDrawingObj.reset( new XclImpChartObj( rHelper ) ); break; 480cdf0e10cSrcweir case BIFF_OBJTYPE_BUTTON: xDrawingObj.reset( new XclImpButtonObj( rHelper ) ); break; 481cdf0e10cSrcweir case BIFF_OBJTYPE_PICTURE: xDrawingObj.reset( new XclImpPictureObj( rHelper ) ); break; 482cdf0e10cSrcweir case BIFF_OBJTYPE_CHECKBOX: xDrawingObj.reset( new XclImpCheckBoxObj( rHelper ) ); break; 483cdf0e10cSrcweir case BIFF_OBJTYPE_OPTIONBUTTON: xDrawingObj.reset( new XclImpOptionButtonObj( rHelper ) ); break; 484cdf0e10cSrcweir case BIFF_OBJTYPE_EDIT: xDrawingObj.reset( new XclImpEditObj( rHelper ) ); break; 485cdf0e10cSrcweir case BIFF_OBJTYPE_LABEL: xDrawingObj.reset( new XclImpLabelObj( rHelper ) ); break; 486cdf0e10cSrcweir case BIFF_OBJTYPE_DIALOG: xDrawingObj.reset( new XclImpDialogObj( rHelper ) ); break; 487cdf0e10cSrcweir case BIFF_OBJTYPE_SPIN: xDrawingObj.reset( new XclImpSpinButtonObj( rHelper ) ); break; 488cdf0e10cSrcweir case BIFF_OBJTYPE_SCROLLBAR: xDrawingObj.reset( new XclImpScrollBarObj( rHelper ) ); break; 489cdf0e10cSrcweir case BIFF_OBJTYPE_LISTBOX: xDrawingObj.reset( new XclImpListBoxObj( rHelper ) ); break; 490cdf0e10cSrcweir case BIFF_OBJTYPE_GROUPBOX: xDrawingObj.reset( new XclImpGroupBoxObj( rHelper ) ); break; 491cdf0e10cSrcweir case BIFF_OBJTYPE_DROPDOWN: xDrawingObj.reset( new XclImpDropDownObj( rHelper ) ); break; 492cdf0e10cSrcweir case BIFF_OBJTYPE_NOTE: xDrawingObj.reset( new XclImpNoteObj( rHelper ) ); break; 493cdf0e10cSrcweir #endif 494cdf0e10cSrcweir 495cdf0e10cSrcweir default: 496cdf0e10cSrcweir #if 0 497cdf0e10cSrcweir OSL_ENSURE( false, "BiffDrawingObjectBase::importObjBiff8 - unknown object type" ); 498cdf0e10cSrcweir #endif 499cdf0e10cSrcweir xDrawingObj.reset( new BiffPlaceholderObject( rHelper ) ); 500cdf0e10cSrcweir } 501cdf0e10cSrcweir } 502cdf0e10cSrcweir } 503cdf0e10cSrcweir 504cdf0e10cSrcweir xDrawingObj->importObjBiff8( rStrm ); 505cdf0e10cSrcweir return xDrawingObj; 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir Reference< XShape > BiffDrawingObjectBase::convertAndInsert( BiffDrawingBase& rDrawing, 509cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle* pParentRect ) const 510cdf0e10cSrcweir { 511cdf0e10cSrcweir Reference< XShape > xShape; 512cdf0e10cSrcweir if( rxShapes.is() && mbProcessShape && !mbHidden ) // TODO: support for hidden objects? 513cdf0e10cSrcweir { 514cdf0e10cSrcweir // base class 'ShapeAnchor' calculates the shape rectangle in 1/100 mm 515cdf0e10cSrcweir // in BIFF3-BIFF5, all shapes have absolute anchor (also children of group shapes) 516cdf0e10cSrcweir Rectangle aShapeRect = maAnchor.calcAnchorRectHmm( getDrawPageSize() ); 517cdf0e10cSrcweir 518cdf0e10cSrcweir // convert the shape, if the calculated rectangle is not empty 519cdf0e10cSrcweir bool bHasWidth = aShapeRect.Width > 0; 520cdf0e10cSrcweir bool bHasHeight = aShapeRect.Height > 0; 521cdf0e10cSrcweir if( mbAreaObj ? (bHasWidth && bHasHeight) : (bHasWidth || bHasHeight) ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir xShape = implConvertAndInsert( rDrawing, rxShapes, aShapeRect ); 524cdf0e10cSrcweir /* Notify the drawing that a new shape has been inserted (but not 525cdf0e10cSrcweir for children of group shapes). For convenience, pass the 526cdf0e10cSrcweir rectangle that contains position and size of the shape. */ 527cdf0e10cSrcweir if( !pParentRect && xShape.is() ) 528cdf0e10cSrcweir rDrawing.notifyShapeInserted( xShape, aShapeRect ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir } 531cdf0e10cSrcweir return xShape; 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir // protected ------------------------------------------------------------------ 535cdf0e10cSrcweir 536cdf0e10cSrcweir void BiffDrawingObjectBase::readNameBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen ) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir maObjName = OUString(); 539cdf0e10cSrcweir if( nNameLen > 0 ) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir // name length field is repeated before the name 542cdf0e10cSrcweir maObjName = rStrm.readByteStringUC( false, getTextEncoding() ); 543cdf0e10cSrcweir // skip padding byte for word boundaries 544cdf0e10cSrcweir rStrm.alignToBlock( 2 ); 545cdf0e10cSrcweir } 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 548cdf0e10cSrcweir void BiffDrawingObjectBase::readMacroBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir maMacroName = OUString(); 551cdf0e10cSrcweir rStrm.skip( nMacroSize ); 552cdf0e10cSrcweir // skip padding byte for word boundaries, not contained in nMacroSize 553cdf0e10cSrcweir rStrm.alignToBlock( 2 ); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir void BiffDrawingObjectBase::readMacroBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir maMacroName = OUString(); 559cdf0e10cSrcweir rStrm.skip( nMacroSize ); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir void BiffDrawingObjectBase::readMacroBiff5( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir maMacroName = OUString(); 565cdf0e10cSrcweir rStrm.skip( nMacroSize ); 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir void BiffDrawingObjectBase::readMacroBiff8( BiffInputStream& rStrm ) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir maMacroName = OUString(); 571cdf0e10cSrcweir if( rStrm.getRemaining() > 6 ) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir // macro is stored in a tNameXR token containing a link to a defined name 574cdf0e10cSrcweir sal_uInt16 nFmlaSize; 575cdf0e10cSrcweir rStrm >> nFmlaSize; 576cdf0e10cSrcweir rStrm.skip( 4 ); 577cdf0e10cSrcweir OSL_ENSURE( nFmlaSize == 7, "BiffDrawingObjectBase::readMacroBiff8 - unexpected formula size" ); 578cdf0e10cSrcweir if( nFmlaSize == 7 ) 579cdf0e10cSrcweir { 580cdf0e10cSrcweir sal_uInt8 nTokenId; 581cdf0e10cSrcweir sal_uInt16 nExtLinkId, nExtNameId; 582cdf0e10cSrcweir rStrm >> nTokenId >> nExtLinkId >> nExtNameId; 583cdf0e10cSrcweir #if 0 584cdf0e10cSrcweir OSL_ENSURE( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ), 585cdf0e10cSrcweir "BiffDrawingObjectBase::readMacroBiff8 - tNameXR token expected" ); 586cdf0e10cSrcweir if( nTokenId == XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX, EXC_TOKCLASS_REF ) ) 587cdf0e10cSrcweir maMacroName = GetLinkManager().GetMacroName( nExtLinkId, nExtNameId ); 588cdf0e10cSrcweir #endif 589cdf0e10cSrcweir } 590cdf0e10cSrcweir } 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir void BiffDrawingObjectBase::convertLineProperties( ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows ) const 594cdf0e10cSrcweir { 595cdf0e10cSrcweir if( rLineModel.mbAuto ) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir BiffObjLineModel aAutoModel; 598cdf0e10cSrcweir aAutoModel.mbAuto = false; 599cdf0e10cSrcweir convertLineProperties( rPropMap, aAutoModel, nArrows ); 600cdf0e10cSrcweir return; 601cdf0e10cSrcweir } 602cdf0e10cSrcweir 603cdf0e10cSrcweir /* Convert line formatting to DrawingML line formatting and let the 604cdf0e10cSrcweir DrawingML code do the hard work. */ 605cdf0e10cSrcweir LineProperties aLineProps; 606cdf0e10cSrcweir 607cdf0e10cSrcweir if( rLineModel.mnStyle == BIFF_OBJ_LINE_NONE ) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir aLineProps.maLineFill.moFillType = XML_noFill; 610cdf0e10cSrcweir } 611cdf0e10cSrcweir else 612cdf0e10cSrcweir { 613cdf0e10cSrcweir aLineProps.maLineFill.moFillType = XML_solidFill; 614cdf0e10cSrcweir aLineProps.maLineFill.maFillColor.setPaletteClr( rLineModel.mnColorIdx ); 615cdf0e10cSrcweir aLineProps.moLineCompound = XML_sng; 616cdf0e10cSrcweir aLineProps.moLineCap = XML_flat; 617cdf0e10cSrcweir aLineProps.moLineJoint = XML_round; 618cdf0e10cSrcweir 619cdf0e10cSrcweir // line width: use 0.35 mm per BIFF line width step 620cdf0e10cSrcweir sal_Int32 nLineWidth = 0; 621cdf0e10cSrcweir switch( rLineModel.mnWidth ) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir default: 624cdf0e10cSrcweir case BIFF_OBJ_LINE_HAIR: nLineWidth = 0; break; 625cdf0e10cSrcweir case BIFF_OBJ_LINE_THIN: nLineWidth = 20; break; 626cdf0e10cSrcweir case BIFF_OBJ_LINE_MEDIUM: nLineWidth = 40; break; 627cdf0e10cSrcweir case BIFF_OBJ_LINE_THICK: nLineWidth = 60; break; 628cdf0e10cSrcweir } 629cdf0e10cSrcweir aLineProps.moLineWidth = getLimitedValue< sal_Int32, sal_Int64 >( convertHmmToEmu( nLineWidth ), 0, SAL_MAX_INT32 ); 630cdf0e10cSrcweir 631cdf0e10cSrcweir // dash style and transparency 632cdf0e10cSrcweir switch( rLineModel.mnStyle ) 633cdf0e10cSrcweir { 634cdf0e10cSrcweir default: 635cdf0e10cSrcweir case BIFF_OBJ_LINE_SOLID: 636cdf0e10cSrcweir aLineProps.moPresetDash = XML_solid; 637cdf0e10cSrcweir break; 638cdf0e10cSrcweir case BIFF_OBJ_LINE_DASH: 639cdf0e10cSrcweir aLineProps.moPresetDash = XML_lgDash; 640cdf0e10cSrcweir break; 641cdf0e10cSrcweir case BIFF_OBJ_LINE_DOT: 642cdf0e10cSrcweir aLineProps.moPresetDash = XML_dot; 643cdf0e10cSrcweir break; 644cdf0e10cSrcweir case BIFF_OBJ_LINE_DASHDOT: 645cdf0e10cSrcweir aLineProps.moPresetDash = XML_lgDashDot; 646cdf0e10cSrcweir break; 647cdf0e10cSrcweir case BIFF_OBJ_LINE_DASHDOTDOT: 648cdf0e10cSrcweir aLineProps.moPresetDash = XML_lgDashDotDot; 649cdf0e10cSrcweir break; 650cdf0e10cSrcweir case BIFF_OBJ_LINE_MEDTRANS: 651cdf0e10cSrcweir aLineProps.moPresetDash = XML_solid; 652cdf0e10cSrcweir aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 50 * PER_PERCENT ); 653cdf0e10cSrcweir break; 654cdf0e10cSrcweir case BIFF_OBJ_LINE_DARKTRANS: 655cdf0e10cSrcweir aLineProps.moPresetDash = XML_solid; 656cdf0e10cSrcweir aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 75 * PER_PERCENT ); 657cdf0e10cSrcweir break; 658cdf0e10cSrcweir case BIFF_OBJ_LINE_LIGHTTRANS: 659cdf0e10cSrcweir aLineProps.moPresetDash = XML_solid; 660cdf0e10cSrcweir aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 25 * PER_PERCENT ); 661cdf0e10cSrcweir break; 662cdf0e10cSrcweir } 663cdf0e10cSrcweir 664cdf0e10cSrcweir // line ends 665cdf0e10cSrcweir bool bLineStart = false; 666cdf0e10cSrcweir bool bLineEnd = false; 667cdf0e10cSrcweir bool bFilled = false; 668cdf0e10cSrcweir switch( extractValue< sal_uInt8 >( nArrows, 0, 4 ) ) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir case BIFF_OBJ_ARROW_OPEN: bLineStart = false; bLineEnd = true; bFilled = false; break; 671cdf0e10cSrcweir case BIFF_OBJ_ARROW_OPENBOTH: bLineStart = true; bLineEnd = true; bFilled = false; break; 672cdf0e10cSrcweir case BIFF_OBJ_ARROW_FILLED: bLineStart = false; bLineEnd = true; bFilled = true; break; 673cdf0e10cSrcweir case BIFF_OBJ_ARROW_FILLEDBOTH: bLineStart = true; bLineEnd = true; bFilled = true; break; 674cdf0e10cSrcweir } 675cdf0e10cSrcweir if( bLineStart || bLineEnd ) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir // arrow type (open or closed) 678cdf0e10cSrcweir sal_Int32 nArrowType = bFilled ? XML_triangle : XML_arrow; 679cdf0e10cSrcweir aLineProps.maStartArrow.moArrowType = bLineStart ? nArrowType : XML_none; 680cdf0e10cSrcweir aLineProps.maEndArrow.moArrowType = bLineEnd ? nArrowType : XML_none; 681cdf0e10cSrcweir 682cdf0e10cSrcweir // arrow width 683cdf0e10cSrcweir sal_Int32 nArrowWidth = XML_med; 684cdf0e10cSrcweir switch( extractValue< sal_uInt8 >( nArrows, 4, 4 ) ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir case BIFF_OBJ_ARROW_NARROW: nArrowWidth = XML_sm; break; 687cdf0e10cSrcweir case BIFF_OBJ_ARROW_MEDIUM: nArrowWidth = XML_med; break; 688cdf0e10cSrcweir case BIFF_OBJ_ARROW_WIDE: nArrowWidth = XML_lg; break; 689cdf0e10cSrcweir } 690cdf0e10cSrcweir aLineProps.maStartArrow.moArrowWidth = aLineProps.maEndArrow.moArrowWidth = nArrowWidth; 691cdf0e10cSrcweir 692cdf0e10cSrcweir // arrow length 693cdf0e10cSrcweir sal_Int32 nArrowLength = XML_med; 694cdf0e10cSrcweir switch( extractValue< sal_uInt8 >( nArrows, 8, 4 ) ) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir case BIFF_OBJ_ARROW_NARROW: nArrowLength = XML_sm; break; 697cdf0e10cSrcweir case BIFF_OBJ_ARROW_MEDIUM: nArrowLength = XML_med; break; 698cdf0e10cSrcweir case BIFF_OBJ_ARROW_WIDE: nArrowLength = XML_lg; break; 699cdf0e10cSrcweir } 700cdf0e10cSrcweir aLineProps.maStartArrow.moArrowLength = aLineProps.maEndArrow.moArrowLength = nArrowLength; 701cdf0e10cSrcweir } 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir aLineProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() ); 705cdf0e10cSrcweir } 706cdf0e10cSrcweir 707cdf0e10cSrcweir void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const 708cdf0e10cSrcweir { 709cdf0e10cSrcweir if( rFillModel.mbAuto ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir BiffObjFillModel aAutoModel; 712cdf0e10cSrcweir aAutoModel.mbAuto = false; 713cdf0e10cSrcweir convertFillProperties( rPropMap, aAutoModel ); 714cdf0e10cSrcweir return; 715cdf0e10cSrcweir } 716cdf0e10cSrcweir 717cdf0e10cSrcweir /* Convert fill formatting to DrawingML fill formatting and let the 718cdf0e10cSrcweir DrawingML code do the hard work. */ 719cdf0e10cSrcweir FillProperties aFillProps; 720cdf0e10cSrcweir 721cdf0e10cSrcweir if( rFillModel.mnPattern == BIFF_OBJ_PATT_NONE ) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir aFillProps.moFillType = XML_noFill; 724cdf0e10cSrcweir } 725cdf0e10cSrcweir else 726cdf0e10cSrcweir { 727cdf0e10cSrcweir const sal_Int32 spnPatternPresets[] = { 728cdf0e10cSrcweir XML_TOKEN_INVALID, XML_TOKEN_INVALID, XML_pct50, XML_pct50, XML_pct25, 729cdf0e10cSrcweir XML_dkHorz, XML_dkVert, XML_dkDnDiag, XML_dkUpDiag, XML_smCheck, XML_trellis, 730cdf0e10cSrcweir XML_ltHorz, XML_ltVert, XML_ltDnDiag, XML_ltUpDiag, XML_smGrid, XML_diagCross, 731cdf0e10cSrcweir XML_pct20, XML_pct10 }; 732cdf0e10cSrcweir sal_Int32 nPatternPreset = STATIC_ARRAY_SELECT( spnPatternPresets, rFillModel.mnPattern, XML_TOKEN_INVALID ); 733cdf0e10cSrcweir if( nPatternPreset == XML_TOKEN_INVALID ) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir aFillProps.moFillType = XML_solidFill; 736cdf0e10cSrcweir aFillProps.maFillColor.setPaletteClr( rFillModel.mnPattColorIdx ); 737cdf0e10cSrcweir } 738cdf0e10cSrcweir else 739cdf0e10cSrcweir { 740cdf0e10cSrcweir aFillProps.moFillType = XML_pattFill; 741cdf0e10cSrcweir aFillProps.maPatternProps.maPattFgColor.setPaletteClr( rFillModel.mnPattColorIdx ); 742cdf0e10cSrcweir aFillProps.maPatternProps.maPattBgColor.setPaletteClr( rFillModel.mnBackColorIdx ); 743cdf0e10cSrcweir aFillProps.maPatternProps.moPattPreset = nPatternPreset; 744cdf0e10cSrcweir } 745cdf0e10cSrcweir #if 0 746cdf0e10cSrcweir static const sal_uInt8 sppnPatterns[][ 8 ] = 747cdf0e10cSrcweir { 748cdf0e10cSrcweir { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 }, 749cdf0e10cSrcweir { 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD }, 750cdf0e10cSrcweir { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 }, 751cdf0e10cSrcweir { 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 }, 752cdf0e10cSrcweir { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC }, 753cdf0e10cSrcweir { 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, 0xCC, 0x99 }, 754cdf0e10cSrcweir { 0xCC, 0x66, 0x33, 0x99, 0xCC, 0x66, 0x33, 0x99 }, 755cdf0e10cSrcweir { 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33 }, 756cdf0e10cSrcweir { 0xCC, 0xFF, 0x33, 0xFF, 0xCC, 0xFF, 0x33, 0xFF }, 757cdf0e10cSrcweir { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00 }, 758cdf0e10cSrcweir { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, 759cdf0e10cSrcweir { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, 760cdf0e10cSrcweir { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, 761cdf0e10cSrcweir { 0xFF, 0x11, 0x11, 0x11, 0xFF, 0x11, 0x11, 0x11 }, 762cdf0e10cSrcweir { 0xAA, 0x44, 0xAA, 0x11, 0xAA, 0x44, 0xAA, 0x11 }, 763cdf0e10cSrcweir { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }, 764cdf0e10cSrcweir { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 } 765cdf0e10cSrcweir }; 766cdf0e10cSrcweir const sal_uInt8* const pnPattern = sppnPatterns[ ::std::min< size_t >( rFillData.mnPattern - 2, STATIC_ARRAY_SIZE( sppnPatterns ) ) ]; 767cdf0e10cSrcweir // create 2-colored 8x8 DIB 768cdf0e10cSrcweir SvMemoryStream aMemStrm; 769cdf0e10cSrcweir // { 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00 } 770cdf0e10cSrcweir aMemStrm << sal_uInt32( 12 ) << sal_Int16( 8 ) << sal_Int16( 8 ) << sal_uInt16( 1 ) << sal_uInt16( 1 ); 771cdf0e10cSrcweir aMemStrm << sal_uInt8( 0xFF ) << sal_uInt8( 0xFF ) << sal_uInt8( 0xFF ); 772cdf0e10cSrcweir aMemStrm << sal_uInt8( 0x00 ) << sal_uInt8( 0x00 ) << sal_uInt8( 0x00 ); 773cdf0e10cSrcweir for( size_t nIdx = 0; nIdx < 8; ++nIdx ) 774cdf0e10cSrcweir aMemStrm << sal_uInt32( pnPattern[ nIdx ] ); // 32-bit little-endian 775cdf0e10cSrcweir aMemStrm.Seek( STREAM_SEEK_TO_BEGIN ); 776cdf0e10cSrcweir Bitmap aBitmap; 777cdf0e10cSrcweir aBitmap.Read( aMemStrm, FALSE ); 778cdf0e10cSrcweir XOBitmap aXOBitmap( aBitmap ); 779cdf0e10cSrcweir aXOBitmap.Bitmap2Array(); 780cdf0e10cSrcweir aXOBitmap.SetBitmapType( XBITMAP_8X8 ); 781cdf0e10cSrcweir if( aXOBitmap.GetBackgroundColor().GetColor() == COL_BLACK ) 782cdf0e10cSrcweir ::std::swap( aPattColor, aBackColor ); 783cdf0e10cSrcweir aXOBitmap.SetPixelColor( aPattColor ); 784cdf0e10cSrcweir aXOBitmap.SetBackgroundColor( aBackColor ); 785cdf0e10cSrcweir rSdrObj.SetMergedItem( XFillStyleItem( XFILL_BITMAP ) ); 786cdf0e10cSrcweir rSdrObj.SetMergedItem( XFillBitmapItem( EMPTY_STRING, aXOBitmap ) ); 787cdf0e10cSrcweir #endif 788cdf0e10cSrcweir } 789cdf0e10cSrcweir 790cdf0e10cSrcweir aFillProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() ); 791cdf0e10cSrcweir } 792cdf0e10cSrcweir 793cdf0e10cSrcweir void BiffDrawingObjectBase::convertFrameProperties( ShapePropertyMap& /*rPropMap*/, sal_uInt16 /*nFrameFlags*/ ) const 794cdf0e10cSrcweir { 795cdf0e10cSrcweir } 796cdf0e10cSrcweir 797cdf0e10cSrcweir void BiffDrawingObjectBase::implReadObjBiff3( BiffInputStream& /*rStrm*/, sal_uInt16 /*nMacroSize*/ ) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir } 800cdf0e10cSrcweir 801cdf0e10cSrcweir void BiffDrawingObjectBase::implReadObjBiff4( BiffInputStream& /*rStrm*/, sal_uInt16 /*nMacroSize*/ ) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir } 804cdf0e10cSrcweir 805cdf0e10cSrcweir void BiffDrawingObjectBase::implReadObjBiff5( BiffInputStream& /*rStrm*/, sal_uInt16 /*nNameLen*/, sal_uInt16 /*nMacroSize*/ ) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir } 808cdf0e10cSrcweir 809cdf0e10cSrcweir void BiffDrawingObjectBase::implReadObjBiff8SubRec( BiffInputStream& /*rStrm*/, sal_uInt16 /*nSubRecId*/, sal_uInt16 /*nSubRecSize*/ ) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir } 812cdf0e10cSrcweir 813cdf0e10cSrcweir // private -------------------------------------------------------------------- 814cdf0e10cSrcweir 815cdf0e10cSrcweir void BiffDrawingObjectBase::importObjBiff3( BiffInputStream& rStrm ) 816cdf0e10cSrcweir { 817cdf0e10cSrcweir // back to offset 4 (ignore object count field) 818cdf0e10cSrcweir rStrm.seek( 4 ); 819cdf0e10cSrcweir 820cdf0e10cSrcweir sal_uInt16 nObjFlags, nMacroSize; 821cdf0e10cSrcweir rStrm >> mnObjType >> mnObjId >> nObjFlags >> maAnchor >> nMacroSize; 822cdf0e10cSrcweir rStrm.skip( 2 ); 823cdf0e10cSrcweir 824cdf0e10cSrcweir mbHasAnchor = true; 825cdf0e10cSrcweir mbHidden = getFlag( nObjFlags, BIFF_OBJ_HIDDEN ); 826cdf0e10cSrcweir mbVisible = getFlag( nObjFlags, BIFF_OBJ_VISIBLE ); 827cdf0e10cSrcweir implReadObjBiff3( rStrm, nMacroSize ); 828cdf0e10cSrcweir } 829cdf0e10cSrcweir 830cdf0e10cSrcweir void BiffDrawingObjectBase::importObjBiff4( BiffInputStream& rStrm ) 831cdf0e10cSrcweir { 832cdf0e10cSrcweir // back to offset 4 (ignore object count field) 833cdf0e10cSrcweir rStrm.seek( 4 ); 834cdf0e10cSrcweir 835cdf0e10cSrcweir sal_uInt16 nObjFlags, nMacroSize; 836cdf0e10cSrcweir rStrm >> mnObjType >> mnObjId >> nObjFlags >> maAnchor >> nMacroSize; 837cdf0e10cSrcweir rStrm.skip( 2 ); 838cdf0e10cSrcweir 839cdf0e10cSrcweir mbHasAnchor = true; 840cdf0e10cSrcweir mbHidden = getFlag( nObjFlags, BIFF_OBJ_HIDDEN ); 841cdf0e10cSrcweir mbVisible = getFlag( nObjFlags, BIFF_OBJ_VISIBLE ); 842cdf0e10cSrcweir mbPrintable = getFlag( nObjFlags, BIFF_OBJ_PRINTABLE ); 843cdf0e10cSrcweir implReadObjBiff4( rStrm, nMacroSize ); 844cdf0e10cSrcweir } 845cdf0e10cSrcweir 846cdf0e10cSrcweir void BiffDrawingObjectBase::importObjBiff5( BiffInputStream& rStrm ) 847cdf0e10cSrcweir { 848cdf0e10cSrcweir // back to offset 4 (ignore object count field) 849cdf0e10cSrcweir rStrm.seek( 4 ); 850cdf0e10cSrcweir 851cdf0e10cSrcweir sal_uInt16 nObjFlags, nMacroSize, nNameLen; 852cdf0e10cSrcweir rStrm >> mnObjType >> mnObjId >> nObjFlags >> maAnchor >> nMacroSize; 853cdf0e10cSrcweir rStrm.skip( 2 ); 854cdf0e10cSrcweir rStrm >> nNameLen; 855cdf0e10cSrcweir rStrm.skip( 2 ); 856cdf0e10cSrcweir 857cdf0e10cSrcweir mbHasAnchor = true; 858cdf0e10cSrcweir mbHidden = getFlag( nObjFlags, BIFF_OBJ_HIDDEN ); 859cdf0e10cSrcweir mbVisible = getFlag( nObjFlags, BIFF_OBJ_VISIBLE ); 860cdf0e10cSrcweir mbPrintable = getFlag( nObjFlags, BIFF_OBJ_PRINTABLE ); 861cdf0e10cSrcweir implReadObjBiff5( rStrm, nNameLen, nMacroSize ); 862cdf0e10cSrcweir } 863cdf0e10cSrcweir 864cdf0e10cSrcweir void BiffDrawingObjectBase::importObjBiff8( BiffInputStream& rStrm ) 865cdf0e10cSrcweir { 866cdf0e10cSrcweir // back to beginning 867cdf0e10cSrcweir rStrm.seekToStart(); 868cdf0e10cSrcweir 869cdf0e10cSrcweir bool bLoop = true; 870cdf0e10cSrcweir while( bLoop && (rStrm.getRemaining() >= 4) ) 871cdf0e10cSrcweir { 872cdf0e10cSrcweir sal_uInt16 nSubRecId, nSubRecSize; 873cdf0e10cSrcweir rStrm >> nSubRecId >> nSubRecSize; 874cdf0e10cSrcweir sal_Int64 nStrmPos = rStrm.tell(); 875cdf0e10cSrcweir // sometimes the last subrecord has an invalid length (OBJLBSDATA) -> min() 876cdf0e10cSrcweir nSubRecSize = static_cast< sal_uInt16 >( ::std::min< sal_Int64 >( nSubRecSize, rStrm.getRemaining() ) ); 877cdf0e10cSrcweir 878cdf0e10cSrcweir switch( nSubRecId ) 879cdf0e10cSrcweir { 880cdf0e10cSrcweir case BIFF_ID_OBJCMO: 881cdf0e10cSrcweir OSL_ENSURE( rStrm.tell() == 4, "BiffDrawingObjectBase::importObjBiff8 - unexpected OBJCMO subrecord" ); 882cdf0e10cSrcweir if( (rStrm.tell() == 4) && (nSubRecSize >= 6) ) 883cdf0e10cSrcweir { 884cdf0e10cSrcweir sal_uInt16 nObjFlags; 885cdf0e10cSrcweir rStrm >> mnObjType >> mnObjId >> nObjFlags; 886cdf0e10cSrcweir mbPrintable = getFlag( nObjFlags, BIFF_OBJCMO_PRINTABLE ); 887cdf0e10cSrcweir } 888cdf0e10cSrcweir break; 889cdf0e10cSrcweir case BIFF_ID_OBJMACRO: 890cdf0e10cSrcweir readMacroBiff8( rStrm ); 891cdf0e10cSrcweir break; 892cdf0e10cSrcweir case BIFF_ID_OBJEND: 893cdf0e10cSrcweir bLoop = false; 894cdf0e10cSrcweir break; 895cdf0e10cSrcweir default: 896cdf0e10cSrcweir implReadObjBiff8SubRec( rStrm, nSubRecId, nSubRecSize ); 897cdf0e10cSrcweir } 898cdf0e10cSrcweir 899cdf0e10cSrcweir // seek to end of subrecord 900cdf0e10cSrcweir rStrm.seek( nStrmPos + nSubRecSize ); 901cdf0e10cSrcweir } 902cdf0e10cSrcweir 903cdf0e10cSrcweir /* Call doReadObj8SubRec() with BIFF_ID_OBJEND for further stream 904cdf0e10cSrcweir processing (e.g. charts), even if the OBJEND subrecord is missing. */ 905cdf0e10cSrcweir implReadObjBiff8SubRec( rStrm, BIFF_ID_OBJEND, 0 ); 906cdf0e10cSrcweir 907cdf0e10cSrcweir /* Pictures that Excel reads from BIFF5 and writes to BIFF8 still have the 908cdf0e10cSrcweir IMGDATA record following the OBJ record (but they use the image data 909cdf0e10cSrcweir stored in DFF). The IMGDATA record may be continued by several CONTINUE 910cdf0e10cSrcweir records. But the last CONTINUE record may be in fact an MSODRAWING 911cdf0e10cSrcweir record that contains the DFF data of the next drawing object! So we 912cdf0e10cSrcweir have to skip just enough CONTINUE records to look at the next 913cdf0e10cSrcweir MSODRAWING/CONTINUE record. */ 914cdf0e10cSrcweir if( (rStrm.getNextRecId() == BIFF3_ID_IMGDATA) && rStrm.startNextRecord() ) 915cdf0e10cSrcweir { 916cdf0e10cSrcweir rStrm.skip( 4 ); 917cdf0e10cSrcweir sal_Int64 nDataSize = rStrm.readuInt32(); 918cdf0e10cSrcweir nDataSize -= rStrm.getRemaining(); 919cdf0e10cSrcweir // skip following CONTINUE records until IMGDATA ends 920cdf0e10cSrcweir while( (nDataSize > 0) && (rStrm.getNextRecId() == BIFF_ID_CONT) && rStrm.startNextRecord() ) 921cdf0e10cSrcweir { 922cdf0e10cSrcweir OSL_ENSURE( nDataSize >= rStrm.getRemaining(), "BiffDrawingObjectBase::importObjBiff8 - CONTINUE too long" ); 923cdf0e10cSrcweir nDataSize -= ::std::min( rStrm.getRemaining(), nDataSize ); 924cdf0e10cSrcweir } 925cdf0e10cSrcweir OSL_ENSURE( nDataSize == 0, "BiffDrawingObjectBase::importObjBiff8 - missing CONTINUE records" ); 926cdf0e10cSrcweir // next record may be MSODRAWING or CONTINUE or anything else 927cdf0e10cSrcweir } 928cdf0e10cSrcweir } 929cdf0e10cSrcweir 930cdf0e10cSrcweir // ============================================================================ 931cdf0e10cSrcweir 932cdf0e10cSrcweir BiffPlaceholderObject::BiffPlaceholderObject( const WorksheetHelper& rHelper ) : 933cdf0e10cSrcweir BiffDrawingObjectBase( rHelper ) 934cdf0e10cSrcweir { 935cdf0e10cSrcweir setProcessShape( false ); 936cdf0e10cSrcweir } 937cdf0e10cSrcweir 938cdf0e10cSrcweir Reference< XShape > BiffPlaceholderObject::implConvertAndInsert( BiffDrawingBase& /*rDrawing*/, 939cdf0e10cSrcweir const Reference< XShapes >& /*rxShapes*/, const Rectangle& /*rShapeRect*/ ) const 940cdf0e10cSrcweir { 941cdf0e10cSrcweir return Reference< XShape >(); 942cdf0e10cSrcweir } 943cdf0e10cSrcweir 944cdf0e10cSrcweir // ============================================================================ 945cdf0e10cSrcweir 946cdf0e10cSrcweir BiffGroupObject::BiffGroupObject( const WorksheetHelper& rHelper ) : 947cdf0e10cSrcweir BiffDrawingObjectBase( rHelper ), 948cdf0e10cSrcweir mnFirstUngrouped( BIFF_OBJ_INVALID_ID ) 949cdf0e10cSrcweir { 950cdf0e10cSrcweir } 951cdf0e10cSrcweir 952cdf0e10cSrcweir bool BiffGroupObject::tryInsert( const BiffDrawingObjectRef& rxDrawingObj ) 953cdf0e10cSrcweir { 954cdf0e10cSrcweir if( rxDrawingObj->getObjId() == mnFirstUngrouped ) 955cdf0e10cSrcweir return false; 956cdf0e10cSrcweir // insert into own list or into nested group 957cdf0e10cSrcweir maChildren.insertGrouped( rxDrawingObj ); 958cdf0e10cSrcweir return true; 959cdf0e10cSrcweir } 960cdf0e10cSrcweir 961cdf0e10cSrcweir void BiffGroupObject::implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir rStrm.skip( 4 ); 964cdf0e10cSrcweir rStrm >> mnFirstUngrouped; 965cdf0e10cSrcweir rStrm.skip( 16 ); 966cdf0e10cSrcweir readMacroBiff3( rStrm, nMacroSize ); 967cdf0e10cSrcweir } 968cdf0e10cSrcweir 969cdf0e10cSrcweir void BiffGroupObject::implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 970cdf0e10cSrcweir { 971cdf0e10cSrcweir rStrm.skip( 4 ); 972cdf0e10cSrcweir rStrm >> mnFirstUngrouped; 973cdf0e10cSrcweir rStrm.skip( 16 ); 974cdf0e10cSrcweir readMacroBiff4( rStrm, nMacroSize ); 975cdf0e10cSrcweir } 976cdf0e10cSrcweir 977cdf0e10cSrcweir void BiffGroupObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) 978cdf0e10cSrcweir { 979cdf0e10cSrcweir rStrm.skip( 4 ); 980cdf0e10cSrcweir rStrm >> mnFirstUngrouped; 981cdf0e10cSrcweir rStrm.skip( 16 ); 982cdf0e10cSrcweir readNameBiff5( rStrm, nNameLen ); 983cdf0e10cSrcweir readMacroBiff5( rStrm, nMacroSize ); 984cdf0e10cSrcweir } 985cdf0e10cSrcweir 986cdf0e10cSrcweir Reference< XShape > BiffGroupObject::implConvertAndInsert( BiffDrawingBase& rDrawing, 987cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const 988cdf0e10cSrcweir { 989cdf0e10cSrcweir Reference< XShape > xGroupShape; 990cdf0e10cSrcweir if( !maChildren.empty() ) try 991cdf0e10cSrcweir { 992cdf0e10cSrcweir xGroupShape = rDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.GroupShape" ), rxShapes, rShapeRect ); 993cdf0e10cSrcweir Reference< XShapes > xChildShapes( xGroupShape, UNO_QUERY_THROW ); 994cdf0e10cSrcweir maChildren.convertAndInsert( rDrawing, xChildShapes, &rShapeRect ); 995cdf0e10cSrcweir // no child shape has been created - delete the group shape 996cdf0e10cSrcweir if( !xChildShapes->hasElements() ) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir rxShapes->remove( xGroupShape ); 999cdf0e10cSrcweir xGroupShape.clear(); 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir } 1002cdf0e10cSrcweir catch( Exception& ) 1003cdf0e10cSrcweir { 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir return xGroupShape; 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir // ============================================================================ 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir BiffLineObject::BiffLineObject( const WorksheetHelper& rHelper ) : 1011cdf0e10cSrcweir BiffDrawingObjectBase( rHelper ), 1012cdf0e10cSrcweir mnArrows( 0 ), 1013cdf0e10cSrcweir mnStartPoint( BIFF_OBJ_LINE_TL ) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir setAreaObj( false ); 1016cdf0e10cSrcweir } 1017cdf0e10cSrcweir 1018cdf0e10cSrcweir void BiffLineObject::implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 1019cdf0e10cSrcweir { 1020cdf0e10cSrcweir rStrm >> maLineModel >> mnArrows >> mnStartPoint; 1021cdf0e10cSrcweir rStrm.skip( 1 ); 1022cdf0e10cSrcweir readMacroBiff3( rStrm, nMacroSize ); 1023cdf0e10cSrcweir } 1024cdf0e10cSrcweir 1025cdf0e10cSrcweir void BiffLineObject::implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 1026cdf0e10cSrcweir { 1027cdf0e10cSrcweir rStrm >> maLineModel >> mnArrows >> mnStartPoint; 1028cdf0e10cSrcweir rStrm.skip( 1 ); 1029cdf0e10cSrcweir readMacroBiff4( rStrm, nMacroSize ); 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir void BiffLineObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir rStrm >> maLineModel >> mnArrows >> mnStartPoint; 1035cdf0e10cSrcweir rStrm.skip( 1 ); 1036cdf0e10cSrcweir readNameBiff5( rStrm, nNameLen ); 1037cdf0e10cSrcweir readMacroBiff5( rStrm, nMacroSize ); 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir Reference< XShape > BiffLineObject::implConvertAndInsert( BiffDrawingBase& rDrawing, 1041cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const 1042cdf0e10cSrcweir { 1043cdf0e10cSrcweir ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); 1044cdf0e10cSrcweir convertLineProperties( aPropMap, maLineModel, mnArrows ); 1045cdf0e10cSrcweir 1046cdf0e10cSrcweir // create the line polygon 1047cdf0e10cSrcweir PointSequenceSequence aPoints( 1 ); 1048cdf0e10cSrcweir aPoints[ 0 ].realloc( 2 ); 1049cdf0e10cSrcweir Point& rBeg = aPoints[ 0 ][ 0 ]; 1050cdf0e10cSrcweir Point& rEnd = aPoints[ 0 ][ 1 ]; 1051cdf0e10cSrcweir sal_Int32 nL = rShapeRect.X; 1052cdf0e10cSrcweir sal_Int32 nT = rShapeRect.Y; 1053cdf0e10cSrcweir sal_Int32 nR = rShapeRect.X + ::std::max< sal_Int32 >( rShapeRect.Width - 1, 0 ); 1054cdf0e10cSrcweir sal_Int32 nB = rShapeRect.Y + ::std::max< sal_Int32 >( rShapeRect.Height - 1, 0 ); 1055cdf0e10cSrcweir switch( mnStartPoint ) 1056cdf0e10cSrcweir { 1057cdf0e10cSrcweir default: 1058cdf0e10cSrcweir case BIFF_OBJ_LINE_TL: rBeg.X = nL; rBeg.Y = nT; rEnd.X = nR; rEnd.Y = nB; break; 1059cdf0e10cSrcweir case BIFF_OBJ_LINE_TR: rBeg.X = nR; rBeg.Y = nT; rEnd.X = nL; rEnd.Y = nB; break; 1060cdf0e10cSrcweir case BIFF_OBJ_LINE_BR: rBeg.X = nR; rBeg.Y = nB; rEnd.X = nL; rEnd.Y = nT; break; 1061cdf0e10cSrcweir case BIFF_OBJ_LINE_BL: rBeg.X = nL; rBeg.Y = nB; rEnd.X = nR; rEnd.Y = nT; break; 1062cdf0e10cSrcweir } 1063cdf0e10cSrcweir aPropMap.setProperty( PROP_PolyPolygon, aPoints ); 1064cdf0e10cSrcweir aPropMap.setProperty( PROP_PolygonKind, PolygonKind_LINE ); 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir // create the shape 1067cdf0e10cSrcweir Reference< XShape > xShape = rDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.LineShape" ), rxShapes, rShapeRect ); 1068cdf0e10cSrcweir PropertySet( xShape ).setProperties( aPropMap ); 1069cdf0e10cSrcweir return xShape; 1070cdf0e10cSrcweir } 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir // ============================================================================ 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir BiffRectObject::BiffRectObject( const WorksheetHelper& rHelper ) : 1075cdf0e10cSrcweir BiffDrawingObjectBase( rHelper ), 1076cdf0e10cSrcweir mnFrameFlags( 0 ) 1077cdf0e10cSrcweir { 1078cdf0e10cSrcweir setAreaObj( true ); 1079cdf0e10cSrcweir } 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir void BiffRectObject::readFrameData( BiffInputStream& rStrm ) 1082cdf0e10cSrcweir { 1083cdf0e10cSrcweir rStrm >> maFillModel >> maLineModel >> mnFrameFlags; 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir 1086cdf0e10cSrcweir void BiffRectObject::convertRectProperties( ShapePropertyMap& rPropMap ) const 1087cdf0e10cSrcweir { 1088cdf0e10cSrcweir convertLineProperties( rPropMap, maLineModel ); 1089cdf0e10cSrcweir convertFillProperties( rPropMap, maFillModel ); 1090cdf0e10cSrcweir convertFrameProperties( rPropMap, mnFrameFlags ); 1091cdf0e10cSrcweir } 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir void BiffRectObject::implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir readFrameData( rStrm ); 1096cdf0e10cSrcweir readMacroBiff3( rStrm, nMacroSize ); 1097cdf0e10cSrcweir } 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir void BiffRectObject::implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 1100cdf0e10cSrcweir { 1101cdf0e10cSrcweir readFrameData( rStrm ); 1102cdf0e10cSrcweir readMacroBiff4( rStrm, nMacroSize ); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir void BiffRectObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) 1106cdf0e10cSrcweir { 1107cdf0e10cSrcweir readFrameData( rStrm ); 1108cdf0e10cSrcweir readNameBiff5( rStrm, nNameLen ); 1109cdf0e10cSrcweir readMacroBiff5( rStrm, nMacroSize ); 1110cdf0e10cSrcweir } 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir Reference< XShape > BiffRectObject::implConvertAndInsert( BiffDrawingBase& rDrawing, 1113cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); 1116cdf0e10cSrcweir convertRectProperties( aPropMap ); 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir Reference< XShape > xShape = rDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.RectangleShape" ), rxShapes, rShapeRect ); 1119cdf0e10cSrcweir PropertySet( xShape ).setProperties( aPropMap ); 1120cdf0e10cSrcweir return xShape; 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir // ============================================================================ 1124cdf0e10cSrcweir 1125cdf0e10cSrcweir BiffOvalObject::BiffOvalObject( const WorksheetHelper& rHelper ) : 1126cdf0e10cSrcweir BiffRectObject( rHelper ) 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir 1130cdf0e10cSrcweir Reference< XShape > BiffOvalObject::implConvertAndInsert( BiffDrawingBase& rDrawing, 1131cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const 1132cdf0e10cSrcweir { 1133cdf0e10cSrcweir ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); 1134cdf0e10cSrcweir convertRectProperties( aPropMap ); 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir Reference< XShape > xShape = rDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.EllipseShape" ), rxShapes, rShapeRect ); 1137cdf0e10cSrcweir PropertySet( xShape ).setProperties( aPropMap ); 1138cdf0e10cSrcweir return xShape; 1139cdf0e10cSrcweir } 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir // ============================================================================ 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir BiffArcObject::BiffArcObject( const WorksheetHelper& rHelper ) : 1144cdf0e10cSrcweir BiffDrawingObjectBase( rHelper ), 1145cdf0e10cSrcweir mnQuadrant( BIFF_OBJ_ARC_TR ) 1146cdf0e10cSrcweir { 1147cdf0e10cSrcweir setAreaObj( false ); // arc may be 2-dimensional 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir void BiffArcObject::implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 1151cdf0e10cSrcweir { 1152cdf0e10cSrcweir rStrm >> maFillModel >> maLineModel >> mnQuadrant; 1153cdf0e10cSrcweir rStrm.skip( 1 ); 1154cdf0e10cSrcweir readMacroBiff3( rStrm, nMacroSize ); 1155cdf0e10cSrcweir } 1156cdf0e10cSrcweir 1157cdf0e10cSrcweir void BiffArcObject::implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 1158cdf0e10cSrcweir { 1159cdf0e10cSrcweir rStrm >> maFillModel >> maLineModel >> mnQuadrant; 1160cdf0e10cSrcweir rStrm.skip( 1 ); 1161cdf0e10cSrcweir readMacroBiff4( rStrm, nMacroSize ); 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir void BiffArcObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) 1165cdf0e10cSrcweir { 1166cdf0e10cSrcweir rStrm >> maFillModel >> maLineModel >> mnQuadrant; 1167cdf0e10cSrcweir rStrm.skip( 1 ); 1168cdf0e10cSrcweir readNameBiff5( rStrm, nNameLen ); 1169cdf0e10cSrcweir readMacroBiff5( rStrm, nMacroSize ); 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir 1172cdf0e10cSrcweir Reference< XShape > BiffArcObject::implConvertAndInsert( BiffDrawingBase& rDrawing, 1173cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const 1174cdf0e10cSrcweir { 1175cdf0e10cSrcweir ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); 1176cdf0e10cSrcweir convertLineProperties( aPropMap, maLineModel ); 1177cdf0e10cSrcweir convertFillProperties( aPropMap, maFillModel ); 1178cdf0e10cSrcweir 1179cdf0e10cSrcweir /* Simulate arc objects with ellipse sections. While the original arc 1180cdf0e10cSrcweir object uses the entire object rectangle, only one quarter of the 1181cdf0e10cSrcweir ellipse shape will be visible. Thus, the size of the ellipse shape 1182cdf0e10cSrcweir needs to be extended and its position adjusted according to the visible 1183cdf0e10cSrcweir quadrant. */ 1184cdf0e10cSrcweir Rectangle aNewRect( rShapeRect.X, rShapeRect.Y, rShapeRect.Width * 2, rShapeRect.Height * 2 ); 1185cdf0e10cSrcweir long nStartAngle = 0; 1186cdf0e10cSrcweir switch( mnQuadrant ) 1187cdf0e10cSrcweir { 1188cdf0e10cSrcweir default: 1189cdf0e10cSrcweir case BIFF_OBJ_ARC_TR: nStartAngle = 0; aNewRect.X -= rShapeRect.Width; break; 1190cdf0e10cSrcweir case BIFF_OBJ_ARC_TL: nStartAngle = 9000; break; 1191cdf0e10cSrcweir case BIFF_OBJ_ARC_BL: nStartAngle = 18000; aNewRect.Y -= rShapeRect.Height; break; 1192cdf0e10cSrcweir case BIFF_OBJ_ARC_BR: nStartAngle = 27000; aNewRect.X -= rShapeRect.Width; aNewRect.Y -= rShapeRect.Height; break; 1193cdf0e10cSrcweir } 1194cdf0e10cSrcweir long nEndAngle = (nStartAngle + 9000) % 36000; 1195cdf0e10cSrcweir aPropMap.setProperty( PROP_CircleKind, maFillModel.isFilled() ? CircleKind_SECTION : CircleKind_ARC ); 1196cdf0e10cSrcweir aPropMap.setProperty( PROP_CircleStartAngle, nStartAngle ); 1197cdf0e10cSrcweir aPropMap.setProperty( PROP_CircleEndAngle, nEndAngle ); 1198cdf0e10cSrcweir 1199cdf0e10cSrcweir // create the shape 1200cdf0e10cSrcweir Reference< XShape > xShape = rDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.EllipseShape" ), rxShapes, aNewRect ); 1201cdf0e10cSrcweir PropertySet( xShape ).setProperties( aPropMap ); 1202cdf0e10cSrcweir return xShape; 1203cdf0e10cSrcweir } 1204cdf0e10cSrcweir 1205cdf0e10cSrcweir // ============================================================================ 1206cdf0e10cSrcweir 1207cdf0e10cSrcweir BiffPolygonObject::BiffPolygonObject( const WorksheetHelper& rHelper ) : 1208cdf0e10cSrcweir BiffRectObject( rHelper ), 1209cdf0e10cSrcweir mnPolyFlags( 0 ), 1210cdf0e10cSrcweir mnPointCount( 0 ) 1211cdf0e10cSrcweir { 1212cdf0e10cSrcweir setAreaObj( false ); // polygon may be 2-dimensional 1213cdf0e10cSrcweir } 1214cdf0e10cSrcweir 1215cdf0e10cSrcweir void BiffPolygonObject::implReadObjBiff4( BiffInputStream& rStrm, sal_uInt16 nMacroSize ) 1216cdf0e10cSrcweir { 1217cdf0e10cSrcweir readFrameData( rStrm ); 1218cdf0e10cSrcweir rStrm >> mnPolyFlags; 1219cdf0e10cSrcweir rStrm.skip( 10 ); 1220cdf0e10cSrcweir rStrm >> mnPointCount; 1221cdf0e10cSrcweir rStrm.skip( 8 ); 1222cdf0e10cSrcweir readMacroBiff4( rStrm, nMacroSize ); 1223cdf0e10cSrcweir importCoordList( rStrm ); 1224cdf0e10cSrcweir } 1225cdf0e10cSrcweir 1226cdf0e10cSrcweir void BiffPolygonObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir readFrameData( rStrm ); 1229cdf0e10cSrcweir rStrm >> mnPolyFlags; 1230cdf0e10cSrcweir rStrm.skip( 10 ); 1231cdf0e10cSrcweir rStrm >> mnPointCount; 1232cdf0e10cSrcweir rStrm.skip( 8 ); 1233cdf0e10cSrcweir readNameBiff5( rStrm, nNameLen ); 1234cdf0e10cSrcweir readMacroBiff5( rStrm, nMacroSize ); 1235cdf0e10cSrcweir importCoordList( rStrm ); 1236cdf0e10cSrcweir } 1237cdf0e10cSrcweir 1238cdf0e10cSrcweir namespace { 1239cdf0e10cSrcweir 1240cdf0e10cSrcweir Point lclGetPolyPoint( const Rectangle& rAnchorRect, const Point& rPoint ) 1241cdf0e10cSrcweir { 1242cdf0e10cSrcweir // polygon coordinates are given in 1/16384 of shape size 1243cdf0e10cSrcweir return Point( 1244cdf0e10cSrcweir rAnchorRect.X + static_cast< sal_Int32 >( rAnchorRect.Width * getLimitedValue< double >( static_cast< double >( rPoint.X ) / 16384.0, 0.0, 1.0 ) + 0.5 ), 1245cdf0e10cSrcweir rAnchorRect.Y + static_cast< sal_Int32 >( rAnchorRect.Height * getLimitedValue< double >( static_cast< double >( rPoint.Y ) / 16384.0, 0.0, 1.0 ) + 0.5 ) ); 1246cdf0e10cSrcweir } 1247cdf0e10cSrcweir 1248cdf0e10cSrcweir } // namespace 1249cdf0e10cSrcweir 1250cdf0e10cSrcweir Reference< XShape > BiffPolygonObject::implConvertAndInsert( BiffDrawingBase& rDrawing, 1251cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const 1252cdf0e10cSrcweir { 1253cdf0e10cSrcweir Reference< XShape > xShape; 1254cdf0e10cSrcweir if( maCoords.size() >= 2 ) 1255cdf0e10cSrcweir { 1256cdf0e10cSrcweir ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); 1257cdf0e10cSrcweir convertRectProperties( aPropMap ); 1258cdf0e10cSrcweir 1259cdf0e10cSrcweir // create the polygon 1260cdf0e10cSrcweir PointVector aPolygon; 1261cdf0e10cSrcweir for( PointVector::const_iterator aIt = maCoords.begin(), aEnd = maCoords.end(); aIt != aEnd; ++aIt ) 1262cdf0e10cSrcweir aPolygon.push_back( lclGetPolyPoint( rShapeRect, *aIt ) ); 1263cdf0e10cSrcweir // close polygon if specified 1264cdf0e10cSrcweir if( getFlag( mnPolyFlags, BIFF_OBJ_POLY_CLOSED ) && ((maCoords.front().X != maCoords.back().X) || (maCoords.front().Y != maCoords.back().Y)) ) 1265cdf0e10cSrcweir aPolygon.push_back( aPolygon.front() ); 1266cdf0e10cSrcweir PointSequenceSequence aPoints( 1 ); 1267cdf0e10cSrcweir aPoints[ 0 ] = ContainerHelper::vectorToSequence( aPolygon ); 1268cdf0e10cSrcweir aPropMap.setProperty( PROP_PolyPolygon, aPoints ); 1269cdf0e10cSrcweir 1270cdf0e10cSrcweir // create the shape 1271cdf0e10cSrcweir OUString aService = maFillModel.isFilled() ? 1272cdf0e10cSrcweir CREATE_OUSTRING( "com.sun.star.drawing.PolyPolygonShape" ) : 1273cdf0e10cSrcweir CREATE_OUSTRING( "com.sun.star.drawing.PolyLineShape" ); 1274cdf0e10cSrcweir xShape = rDrawing.createAndInsertXShape( aService, rxShapes, rShapeRect ); 1275cdf0e10cSrcweir PropertySet( xShape ).setProperties( aPropMap ); 1276cdf0e10cSrcweir } 1277cdf0e10cSrcweir return xShape; 1278cdf0e10cSrcweir } 1279cdf0e10cSrcweir 1280cdf0e10cSrcweir void BiffPolygonObject::importCoordList( BiffInputStream& rStrm ) 1281cdf0e10cSrcweir { 1282cdf0e10cSrcweir if( (rStrm.getNextRecId() == BIFF_ID_COORDLIST) && rStrm.startNextRecord() ) 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir OSL_ENSURE( rStrm.getRemaining() / 4 == mnPointCount, "BiffPolygonObject::importCoordList - wrong polygon point count" ); 1285cdf0e10cSrcweir while( rStrm.getRemaining() >= 4 ) 1286cdf0e10cSrcweir { 1287cdf0e10cSrcweir sal_uInt16 nX, nY; 1288cdf0e10cSrcweir rStrm >> nX >> nY; 1289cdf0e10cSrcweir maCoords.push_back( Point( nX, nY ) ); 1290cdf0e10cSrcweir } 1291cdf0e10cSrcweir } 1292cdf0e10cSrcweir } 1293cdf0e10cSrcweir 1294cdf0e10cSrcweir // ============================================================================ 1295cdf0e10cSrcweir // BIFF drawing page 1296cdf0e10cSrcweir // ============================================================================ 1297cdf0e10cSrcweir 1298cdf0e10cSrcweir BiffDrawingBase::BiffDrawingBase( const WorksheetHelper& rHelper, const Reference< XDrawPage >& rxDrawPage ) : 1299cdf0e10cSrcweir WorksheetHelper( rHelper ), 1300cdf0e10cSrcweir mxDrawPage( rxDrawPage ) 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir } 1303cdf0e10cSrcweir 1304cdf0e10cSrcweir void BiffDrawingBase::importObj( BiffInputStream& rStrm ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir BiffDrawingObjectRef xDrawingObj; 1307cdf0e10cSrcweir 1308cdf0e10cSrcweir #if 0 1309cdf0e10cSrcweir /* #i61786# In BIFF8 streams, OBJ records may occur without MSODRAWING 1310cdf0e10cSrcweir records. In this case, the OBJ records are in BIFF5 format. Do a sanity 1311cdf0e10cSrcweir check here that there is no DFF data loaded before. */ 1312cdf0e10cSrcweir DBG_ASSERT( maDffStrm.Tell() == 0, "BiffDrawingBase::importObj - unexpected DFF stream data, OBJ will be ignored" ); 1313cdf0e10cSrcweir if( maDffStrm.Tell() == 0 ) switch( GetBiff() ) 1314cdf0e10cSrcweir #else 1315cdf0e10cSrcweir switch( getBiff() ) 1316cdf0e10cSrcweir #endif 1317cdf0e10cSrcweir { 1318cdf0e10cSrcweir case BIFF3: 1319cdf0e10cSrcweir xDrawingObj = BiffDrawingObjectBase::importObjBiff3( *this, rStrm ); 1320cdf0e10cSrcweir break; 1321cdf0e10cSrcweir case BIFF4: 1322cdf0e10cSrcweir xDrawingObj = BiffDrawingObjectBase::importObjBiff4( *this, rStrm ); 1323cdf0e10cSrcweir break; 1324cdf0e10cSrcweir case BIFF5: 1325cdf0e10cSrcweir // TODO: add BIFF8 when DFF is supported 1326cdf0e10cSrcweir // case BIFF8: 1327cdf0e10cSrcweir xDrawingObj = BiffDrawingObjectBase::importObjBiff5( *this, rStrm ); 1328cdf0e10cSrcweir break; 1329cdf0e10cSrcweir default:; 1330cdf0e10cSrcweir } 1331cdf0e10cSrcweir 1332cdf0e10cSrcweir if( xDrawingObj.get() ) 1333cdf0e10cSrcweir { 1334cdf0e10cSrcweir // insert into maRawObjs or into the last open group object 1335cdf0e10cSrcweir maRawObjs.insertGrouped( xDrawingObj ); 1336cdf0e10cSrcweir // to be able to find objects by ID 1337cdf0e10cSrcweir maObjMapId[ xDrawingObj->getObjId() ] = xDrawingObj; 1338cdf0e10cSrcweir } 1339cdf0e10cSrcweir } 1340cdf0e10cSrcweir 1341cdf0e10cSrcweir void BiffDrawingBase::setSkipObj( sal_uInt16 nObjId ) 1342cdf0e10cSrcweir { 1343cdf0e10cSrcweir /* Store identifiers of objects to be skipped in a separate list (the OBJ 1344cdf0e10cSrcweir record may not be read yet). In the finalization phase, all objects 1345cdf0e10cSrcweir registered here will be skipped. */ 1346cdf0e10cSrcweir maSkipObjs.push_back( nObjId ); 1347cdf0e10cSrcweir } 1348cdf0e10cSrcweir 1349cdf0e10cSrcweir void BiffDrawingBase::finalizeImport() 1350cdf0e10cSrcweir { 1351cdf0e10cSrcweir Reference< XShapes > xShapes( mxDrawPage, UNO_QUERY ); 1352cdf0e10cSrcweir OSL_ENSURE( xShapes.is(), "BiffDrawingBase::finalizeImport - no shapes container" ); 1353cdf0e10cSrcweir if( !xShapes.is() ) 1354cdf0e10cSrcweir return; 1355cdf0e10cSrcweir 1356cdf0e10cSrcweir // process list of objects to be skipped 1357cdf0e10cSrcweir for( BiffObjIdVector::const_iterator aIt = maSkipObjs.begin(), aEnd = maSkipObjs.end(); aIt != aEnd; ++aIt ) 1358cdf0e10cSrcweir if( BiffDrawingObjectBase* pDrawingObj = maObjMapId.get( *aIt ).get() ) 1359cdf0e10cSrcweir pDrawingObj->setProcessShape( false ); 1360cdf0e10cSrcweir 1361cdf0e10cSrcweir // process drawing objects without DFF data 1362cdf0e10cSrcweir maRawObjs.convertAndInsert( *this, xShapes ); 1363cdf0e10cSrcweir } 1364cdf0e10cSrcweir 1365cdf0e10cSrcweir Reference< XShape > BiffDrawingBase::createAndInsertXShape( const OUString& rService, 1366cdf0e10cSrcweir const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const 1367cdf0e10cSrcweir { 1368cdf0e10cSrcweir OSL_ENSURE( rService.getLength() > 0, "BiffDrawingBase::createAndInsertXShape - missing UNO shape service name" ); 1369cdf0e10cSrcweir OSL_ENSURE( rxShapes.is(), "BiffDrawingBase::createAndInsertXShape - missing XShapes container" ); 1370cdf0e10cSrcweir Reference< XShape > xShape; 1371cdf0e10cSrcweir if( (rService.getLength() > 0) && rxShapes.is() ) try 1372cdf0e10cSrcweir { 1373cdf0e10cSrcweir xShape.set( getBaseFilter().getModelFactory()->createInstance( rService ), UNO_QUERY_THROW ); 1374cdf0e10cSrcweir // insert shape into passed shape collection (maybe drawpage or group shape) 1375cdf0e10cSrcweir rxShapes->add( xShape ); 1376cdf0e10cSrcweir xShape->setPosition( Point( rShapeRect.X, rShapeRect.Y ) ); 1377cdf0e10cSrcweir xShape->setSize( Size( rShapeRect.Width, rShapeRect.Height ) ); 1378cdf0e10cSrcweir } 1379cdf0e10cSrcweir catch( Exception& ) 1380cdf0e10cSrcweir { 1381cdf0e10cSrcweir } 1382cdf0e10cSrcweir OSL_ENSURE( xShape.is(), "BiffDrawingBase::createAndInsertXShape - cannot instanciate shape object" ); 1383cdf0e10cSrcweir return xShape; 1384cdf0e10cSrcweir } 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir // protected ------------------------------------------------------------------ 1387cdf0e10cSrcweir 1388cdf0e10cSrcweir void BiffDrawingBase::appendRawObject( const BiffDrawingObjectRef& rxDrawingObj ) 1389cdf0e10cSrcweir { 1390cdf0e10cSrcweir OSL_ENSURE( rxDrawingObj.get(), "BiffDrawingBase::appendRawObject - unexpected empty object reference" ); 1391cdf0e10cSrcweir maRawObjs.append( rxDrawingObj ); 1392cdf0e10cSrcweir } 1393cdf0e10cSrcweir 1394cdf0e10cSrcweir // ============================================================================ 1395cdf0e10cSrcweir 1396cdf0e10cSrcweir BiffSheetDrawing::BiffSheetDrawing( const WorksheetHelper& rHelper ) : 1397cdf0e10cSrcweir BiffDrawingBase( rHelper, rHelper.getDrawPage() ) 1398cdf0e10cSrcweir { 1399cdf0e10cSrcweir } 1400cdf0e10cSrcweir 1401cdf0e10cSrcweir void BiffSheetDrawing::notifyShapeInserted( const Reference< XShape >& /*rxShape*/, const Rectangle& rShapeRect ) 1402cdf0e10cSrcweir { 1403cdf0e10cSrcweir // collect all shape positions in the WorksheetHelper base class 1404cdf0e10cSrcweir extendShapeBoundingBox( rShapeRect ); 1405cdf0e10cSrcweir } 1406cdf0e10cSrcweir 1407cdf0e10cSrcweir // ============================================================================ 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir } // namespace xls 1410cdf0e10cSrcweir } // namespace oox 1411