LCOV - code coverage report
Current view: top level - libreoffice/oox/source/export - shapes.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 475 0.2 %
Date: 2012-12-17 Functions: 2 33 6.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <comphelper/mediadescriptor.hxx>
      21             : #include "oox/core/xmlfilterbase.hxx"
      22             : #include "oox/export/shapes.hxx"
      23             : #include "oox/export/utils.hxx"
      24             : #include <oox/token/tokens.hxx>
      25             : 
      26             : #include <cstdio>
      27             : #include <com/sun/star/awt/CharSet.hpp>
      28             : #include <com/sun/star/awt/FontDescriptor.hpp>
      29             : #include <com/sun/star/awt/FontSlant.hpp>
      30             : #include <com/sun/star/awt/FontWeight.hpp>
      31             : #include <com/sun/star/awt/FontUnderline.hpp>
      32             : #include <com/sun/star/awt/Gradient.hpp>
      33             : #include <com/sun/star/beans/XPropertySet.hpp>
      34             : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      35             : #include <com/sun/star/beans/XPropertyState.hpp>
      36             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      37             : #include <com/sun/star/document/XExporter.hpp>
      38             : #include <com/sun/star/drawing/FillStyle.hpp>
      39             : #include <com/sun/star/drawing/BitmapMode.hpp>
      40             : #include <com/sun/star/drawing/ConnectorType.hpp>
      41             : #include <com/sun/star/drawing/LineDash.hpp>
      42             : #include <com/sun/star/drawing/LineJoint.hpp>
      43             : #include <com/sun/star/drawing/LineStyle.hpp>
      44             : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
      45             : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      46             : #include <com/sun/star/graphic/XGraphic.hpp>
      47             : #include <com/sun/star/i18n/ScriptType.hpp>
      48             : #include <com/sun/star/io/XOutputStream.hpp>
      49             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      50             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      51             : #include <com/sun/star/text/XSimpleText.hpp>
      52             : #include <com/sun/star/text/XText.hpp>
      53             : #include <com/sun/star/text/XTextContent.hpp>
      54             : #include <com/sun/star/text/XTextField.hpp>
      55             : #include <com/sun/star/text/XTextRange.hpp>
      56             : #include <com/sun/star/table/XTable.hpp>
      57             : #include <com/sun/star/table/XColumnRowRange.hpp>
      58             : #include <com/sun/star/table/XCellRange.hpp>
      59             : #include <com/sun/star/table/XMergeableCell.hpp>
      60             : #include <com/sun/star/chart2/XChartDocument.hpp>
      61             : #include <com/sun/star/frame/XModel.hpp>
      62             : #include <tools/stream.hxx>
      63             : #include <tools/string.hxx>
      64             : #include <vcl/cvtgrf.hxx>
      65             : #include <unotools/fontcvt.hxx>
      66             : #include <vcl/graph.hxx>
      67             : #include <vcl/outdev.hxx>
      68             : #include <svtools/grfmgr.hxx>
      69             : #include <rtl/strbuf.hxx>
      70             : #include <sfx2/app.hxx>
      71             : #include <svl/languageoptions.hxx>
      72             : #include <filter/msfilter/escherex.hxx>
      73             : #include <svx/svdoashp.hxx>
      74             : #include <svx/svdoole2.hxx>
      75             : #include <editeng/svxenum.hxx>
      76             : #include <svx/unoapi.hxx>
      77             : #include <oox/export/chartexport.hxx>
      78             : 
      79             : using namespace ::com::sun::star;
      80             : using namespace ::com::sun::star::beans;
      81             : using namespace ::com::sun::star::uno;
      82             : using namespace ::com::sun::star::drawing;
      83             : using namespace ::com::sun::star::i18n;
      84             : using namespace ::com::sun::star::table;
      85             : using ::com::sun::star::beans::PropertyState;
      86             : using ::com::sun::star::beans::PropertyValue;
      87             : using ::com::sun::star::beans::XPropertySet;
      88             : using ::com::sun::star::beans::XPropertyState;
      89             : using ::com::sun::star::container::XEnumeration;
      90             : using ::com::sun::star::container::XEnumerationAccess;
      91             : using ::com::sun::star::container::XIndexAccess;
      92             : using ::com::sun::star::document::XExporter;
      93             : using ::com::sun::star::document::XFilter;
      94             : using ::com::sun::star::drawing::FillStyle;
      95             : using ::com::sun::star::graphic::XGraphic;
      96             : using ::com::sun::star::io::XOutputStream;
      97             : using ::com::sun::star::lang::XComponent;
      98             : using ::com::sun::star::text::XSimpleText;
      99             : using ::com::sun::star::text::XText;
     100             : using ::com::sun::star::text::XTextContent;
     101             : using ::com::sun::star::text::XTextField;
     102             : using ::com::sun::star::text::XTextRange;
     103             : using ::oox::core::XmlFilterBase;
     104             : using ::com::sun::star::chart2::XChartDocument;
     105             : using ::com::sun::star::frame::XModel;
     106             : using ::com::sun::star::sheet::XSpreadsheetDocument;
     107             : using ::comphelper::MediaDescriptor;
     108             : using ::oox::core::XmlFilterBase;
     109             : using ::rtl::OString;
     110             : using ::rtl::OStringBuffer;
     111             : using ::rtl::OUString;
     112             : using ::rtl::OUStringBuffer;
     113             : using ::sax_fastparser::FSHelperPtr;
     114             : 
     115             : #define IDS(x) OString(OStringLiteral(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr()
     116             : 
     117             : struct CustomShapeTypeTranslationTable
     118             : {
     119             :     const char* sOOo;
     120             :     const char* sMSO;
     121             : };
     122             : 
     123             : static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] =
     124             : {
     125             :     // { "non-primitive", mso_sptMin },
     126             :     { "rectangle", "rect" },
     127             :     { "round-rectangle", "roundRect" },
     128             :     { "ellipse", "ellipse" },
     129             :     { "diamond", "diamond" },
     130             :     { "isosceles-triangle", "triangle" },
     131             :     { "right-triangle", "rtTriangle" },
     132             :     { "parallelogram", "parallelogram" },
     133             :     { "trapezoid", "trapezoid" },
     134             :     { "hexagon", "hexagon" },
     135             :     { "octagon", "octagon" },
     136             :     { "cross", "plus" },
     137             :     { "star5", "star5" },
     138             :     { "right-arrow", "rightArrow" },
     139             :     // { "mso-spt14", mso_sptThickArrow },
     140             :     { "pentagon-right", "homePlate" },
     141             :     { "cube", "cube" },
     142             :     // { "mso-spt17", mso_sptBalloon },
     143             :     // { "mso-spt18", mso_sptSeal },
     144             :     { "mso-spt19", "arc" },
     145             :     { "mso-spt20", "line" },
     146             :     { "mso-spt21", "plaque" },
     147             :     { "can", "can" },
     148             :     { "ring", "donut" },
     149             :     { "mso-spt24", "textSimple" },
     150             :     { "mso-spt25", "textOctagon" },
     151             :     { "mso-spt26", "textHexagon" },
     152             :     { "mso-spt27", "textCurve" },
     153             :     { "mso-spt28", "textWave" },
     154             :     { "mso-spt29", "textRing" },
     155             :     { "mso-spt30", "textOnCurve" },
     156             :     { "mso-spt31", "textOnRing" },
     157             :     { "mso-spt32", "straightConnector1" },
     158             :     { "mso-spt33", "bentConnector2" },
     159             :     { "mso-spt34", "bentConnector3" },
     160             :     { "mso-spt35", "bentConnector4" },
     161             :     { "mso-spt36", "bentConnector5" },
     162             :     { "mso-spt37", "curvedConnector2" },
     163             :     { "mso-spt38", "curvedConnector3" },
     164             :     { "mso-spt39", "curvedConnector4" },
     165             :     { "mso-spt40", "curvedConnector5" },
     166             :     { "mso-spt41", "callout1" },
     167             :     { "mso-spt42", "callout2" },
     168             :     { "mso-spt43", "callout3" },
     169             :     { "mso-spt44", "accentCallout1" },
     170             :     { "mso-spt45", "accentCallout2" },
     171             :     { "mso-spt46", "accentCallout3" },
     172             :     { "line-callout-1", "borderCallout1" },
     173             :     { "line-callout-2", "borderCallout2" },
     174             :     { "line-callout-3", "borderCallout3" },
     175             :     { "mso-spt49", "accentBorderCallout90" },
     176             :     { "mso-spt50", "accentBorderCallout1" },
     177             :     { "mso-spt51", "accentBorderCallout2" },
     178             :     { "mso-spt52", "accentBorderCallout3" },
     179             :     { "mso-spt53", "ribbon" },
     180             :     { "mso-spt54", "ribbon2" },
     181             :     { "chevron", "chevron" },
     182             :     { "pentagon", "pentagon" },
     183             :     { "forbidden", "noSmoking" },
     184             :     { "star8", "seal8" },
     185             :     { "mso-spt59", "seal16" },
     186             :     { "mso-spt60", "seal32" },
     187             :     { "rectangular-callout", "wedgeRectCallout" },
     188             :     { "round-rectangular-callout", "wedgeRoundRectCallout" },
     189             :     { "round-callout", "wedgeEllipseCallout" },
     190             :     { "mso-spt64", "wave" },
     191             :     { "paper", "foldedCorner" },
     192             :     { "left-arrow", "leftArrow" },
     193             :     { "down-arrow", "downArrow" },
     194             :     { "up-arrow", "upArrow" },
     195             :     { "left-right-arrow", "leftRightArrow" },
     196             :     { "up-down-arrow", "upDownArrow" },
     197             :     { "mso-spt71", "irregularSeal1" },
     198             :     { "bang", "irregularSeal2" },
     199             :     { "lightning", "lightningBolt" },
     200             :     { "heart", "heart" },
     201             :     { "mso-spt75", "pictureFrame" },
     202             :     { "quad-arrow", "quadArrow" },
     203             :     { "left-arrow-callout", "leftArrowCallout" },
     204             :     { "right-arrow-callout", "rightArrowCallout" },
     205             :     { "up-arrow-callout", "upArrowCallout" },
     206             :     { "down-arrow-callout", "downArrowCallout" },
     207             :     { "left-right-arrow-callout", "leftRightArrowCallout" },
     208             :     { "up-down-arrow-callout", "upDownArrowCallout" },
     209             :     { "quad-arrow-callout", "quadArrowCallout" },
     210             :     { "quad-bevel", "bevel" },
     211             :     { "left-bracket", "leftBracket" },
     212             :     { "right-bracket", "rightBracket" },
     213             :     { "left-brace", "leftBrace" },
     214             :     { "right-brace", "rightBrace" },
     215             :     { "mso-spt89", "leftUpArrow" },
     216             :     { "mso-spt90", "bentUpArrow" },
     217             :     { "mso-spt91", "bentArrow" },
     218             :     { "star24", "seal24" },
     219             :     { "striped-right-arrow", "stripedRightArrow" },
     220             :     { "notched-right-arrow", "notchedRightArrow" },
     221             :     { "block-arc", "blockArc" },
     222             :     { "smiley", "smileyFace" },
     223             :     { "vertical-scroll", "verticalScroll" },
     224             :     { "horizontal-scroll", "horizontalScroll" },
     225             :     { "circular-arrow", "circularArrow" },
     226             :     { "mso-spt100", "pie" }, // looks like MSO_SPT is wrong here
     227             :     { "mso-spt101", "uturnArrow" },
     228             :     { "mso-spt102", "curvedRightArrow" },
     229             :     { "mso-spt103", "curvedLeftArrow" },
     230             :     { "mso-spt104", "curvedUpArrow" },
     231             :     { "mso-spt105", "curvedDownArrow" },
     232             :     { "cloud-callout", "cloudCallout" },
     233             :     { "mso-spt107", "ellipseRibbon" },
     234             :     { "mso-spt108", "ellipseRibbon2" },
     235             :     { "flowchart-process", "flowChartProcess" },
     236             :     { "flowchart-decision", "flowChartDecision" },
     237             :     { "flowchart-data", "flowChartInputOutput" },
     238             :     { "flowchart-predefined-process", "flowChartPredefinedProcess" },
     239             :     { "flowchart-internal-storage", "flowChartInternalStorage" },
     240             :     { "flowchart-document", "flowChartDocument" },
     241             :     { "flowchart-multidocument", "flowChartMultidocument" },
     242             :     { "flowchart-terminator", "flowChartTerminator" },
     243             :     { "flowchart-preparation", "flowChartPreparation" },
     244             :     { "flowchart-manual-input", "flowChartManualInput" },
     245             :     { "flowchart-manual-operation", "flowChartManualOperation" },
     246             :     { "flowchart-connector", "flowChartConnector" },
     247             :     { "flowchart-card", "flowChartPunchedCard" },
     248             :     { "flowchart-punched-tape", "flowChartPunchedTape" },
     249             :     { "flowchart-summing-junction", "flowChartSummingJunction" },
     250             :     { "flowchart-or", "flowChartOr" },
     251             :     { "flowchart-collate", "flowChartCollate" },
     252             :     { "flowchart-sort", "flowChartSort" },
     253             :     { "flowchart-extract", "flowChartExtract" },
     254             :     { "flowchart-merge", "flowChartMerge" },
     255             :     { "mso-spt129", "flowChartOfflineStorage" },
     256             :     { "flowchart-stored-data", "flowChartOnlineStorage" },
     257             :     { "flowchart-sequential-access", "flowChartMagneticTape" },
     258             :     { "flowchart-magnetic-disk", "flowChartMagneticDisk" },
     259             :     { "flowchart-direct-access-storage", "flowChartMagneticDrum" },
     260             :     { "flowchart-display", "flowChartDisplay" },
     261             :     { "flowchart-delay", "flowChartDelay" },
     262             :     { "fontwork-plain-text", "textPlainText" },
     263             :     { "fontwork-stop", "textStop" },
     264             :     { "fontwork-triangle-up", "textTriangle" },
     265             :     { "fontwork-triangle-down", "textTriangleInverted" },
     266             :     { "fontwork-chevron-up", "textChevron" },
     267             :     { "fontwork-chevron-down", "textChevronInverted" },
     268             :     { "mso-spt142", "textRingInside" },
     269             :     { "mso-spt143", "textRingOutside" },
     270             :     { "fontwork-arch-up-curve", "textArchUpCurve" },
     271             :     { "fontwork-arch-down-curve", "textArchDownCurve" },
     272             :     { "fontwork-circle-curve", "textCircleCurve" },
     273             :     { "fontwork-open-circle-curve", "textButtonCurve" },
     274             :     { "fontwork-arch-up-pour", "textArchUpPour" },
     275             :     { "fontwork-arch-down-pour", "textArchDownPour" },
     276             :     { "fontwork-circle-pour", "textCirclePour" },
     277             :     { "fontwork-open-circle-pour", "textButtonPour" },
     278             :     { "fontwork-curve-up", "textCurveUp" },
     279             :     { "fontwork-curve-down", "textCurveDown" },
     280             :     { "fontwork-fade-up-and-right", "textCascadeUp" },
     281             :     { "fontwork-fade-up-and-left", "textCascadeDown" },
     282             :     { "fontwork-wave", "textWave1" },
     283             :     { "mso-spt157", "textWave2" },
     284             :     { "mso-spt158", "textWave3" },
     285             :     { "mso-spt159", "textWave4" },
     286             :     { "fontwork-inflate", "textInflate" },
     287             :     { "mso-spt161", "textDeflate" },
     288             :     { "mso-spt162", "textInflateBottom" },
     289             :     { "mso-spt163", "textDeflateBottom" },
     290             :     { "mso-spt164", "textInflateTop" },
     291             :     { "mso-spt165", "textDeflateTop" },
     292             :     { "mso-spt166", "textDeflateInflate" },
     293             :     { "mso-spt167", "textDeflateInflateDeflate" },
     294             :     { "fontwork-fade-right", "textFadeRight" },
     295             :     { "fontwork-fade-left", "textFadeLeft" },
     296             :     { "fontwork-fade-up", "textFadeUp" },
     297             :     { "fontwork-fade-down", "textFadeDown" },
     298             :     { "fontwork-slant-up", "textSlantUp" },
     299             :     { "fontwork-slant-down", "textSlantDown" },
     300             :     { "mso-spt174", "textCanUp" },
     301             :     { "mso-spt175", "textCanDown" },
     302             :     { "flowchart-alternate-process", "flowChartAlternateProcess" },
     303             :     { "flowchart-off-page-connector", "flowChartOffpageConnector" },
     304             :     { "mso-spt178", "callout90" },
     305             :     { "mso-spt179", "accentCallout90" },
     306             :     { "mso-spt180", "borderCallout90" },
     307             :     { "mso-spt182", "leftRightUpArrow" },
     308             :     { "sun", "sun" },
     309             :     { "moon", "moon" },
     310             :     { "bracket-pair", "bracketPair" },
     311             :     { "brace-pair", "bracePair" },
     312             :     { "star4", "seal4" },
     313             :     { "mso-spt188", "doubleWave" },
     314             :     { "mso-spt189", "actionButtonBlank" },
     315             :     { "mso-spt190", "actionButtonHome" },
     316             :     { "mso-spt191", "actionButtonHelp" },
     317             :     { "mso-spt192", "actionButtonInformation" },
     318             :     { "mso-spt193", "actionButtonForwardNext" },
     319             :     { "mso-spt194", "actionButtonBackPrevious" },
     320             :     { "mso-spt195", "actionButtonEnd" },
     321             :     { "mso-spt196", "actionButtonBeginning" },
     322             :     { "mso-spt197", "actionButtonReturn" },
     323             :     { "mso-spt198", "actionButtonDocument" },
     324             :     { "mso-spt199", "actionButtonSound" },
     325             :     { "mso-spt200", "actionButtonMovie" },
     326             :     { "mso-spt201", "hostControl" },
     327             :     { "mso-spt202", "rect" },
     328             :     { "ooxml-actionButtonSound", "actionButtonSound" },
     329             :     { "ooxml-borderCallout1", "borderCallout1" },
     330             :     { "ooxml-plaqueTabs", "plaqueTabs" },
     331             :     { "ooxml-curvedLeftArrow", "curvedLeftArrow" },
     332             :     { "ooxml-octagon", "octagon" },
     333             :     { "ooxml-leftRightRibbon", "leftRightRibbon" },
     334             :     { "ooxml-actionButtonInformation", "actionButtonInformation" },
     335             :     { "ooxml-bentConnector5", "bentConnector5" },
     336             :     { "ooxml-circularArrow", "circularArrow" },
     337             :     { "ooxml-downArrowCallout", "downArrowCallout" },
     338             :     { "ooxml-mathMinus", "mathMinus" },
     339             :     { "ooxml-gear9", "gear9" },
     340             :     { "ooxml-round1Rect", "round1Rect" },
     341             :     { "ooxml-sun", "sun" },
     342             :     { "ooxml-plaque", "plaque" },
     343             :     { "ooxml-chevron", "chevron" },
     344             :     { "ooxml-flowChartPreparation", "flowChartPreparation" },
     345             :     { "ooxml-diagStripe", "diagStripe" },
     346             :     { "ooxml-pentagon", "pentagon" },
     347             :     { "ooxml-funnel", "funnel" },
     348             :     { "ooxml-chartStar", "chartStar" },
     349             :     { "ooxml-accentBorderCallout1", "accentBorderCallout1" },
     350             :     { "ooxml-notchedRightArrow", "notchedRightArrow" },
     351             :     { "ooxml-rightBracket", "rightBracket" },
     352             :     { "ooxml-flowChartOffpageConnector", "flowChartOffpageConnector" },
     353             :     { "ooxml-leftRightArrow", "leftRightArrow" },
     354             :     { "ooxml-decagon", "decagon" },
     355             :     { "ooxml-actionButtonHelp", "actionButtonHelp" },
     356             :     { "ooxml-star24", "star24" },
     357             :     { "ooxml-mathDivide", "mathDivide" },
     358             :     { "ooxml-curvedConnector4", "curvedConnector4" },
     359             :     { "ooxml-flowChartOr", "flowChartOr" },
     360             :     { "ooxml-borderCallout3", "borderCallout3" },
     361             :     { "ooxml-upDownArrowCallout", "upDownArrowCallout" },
     362             :     { "ooxml-flowChartDecision", "flowChartDecision" },
     363             :     { "ooxml-leftRightArrowCallout", "leftRightArrowCallout" },
     364             :     { "ooxml-flowChartManualOperation", "flowChartManualOperation" },
     365             :     { "ooxml-snipRoundRect", "snipRoundRect" },
     366             :     { "ooxml-mathPlus", "mathPlus" },
     367             :     { "ooxml-actionButtonForwardNext", "actionButtonForwardNext" },
     368             :     { "ooxml-can", "can" },
     369             :     { "ooxml-foldedCorner", "foldedCorner" },
     370             :     { "ooxml-star32", "star32" },
     371             :     { "ooxml-flowChartInternalStorage", "flowChartInternalStorage" },
     372             :     { "ooxml-upDownArrow", "upDownArrow" },
     373             :     { "ooxml-irregularSeal2", "irregularSeal2" },
     374             :     { "ooxml-mathEqual", "mathEqual" },
     375             :     { "ooxml-star12", "star12" },
     376             :     { "ooxml-uturnArrow", "uturnArrow" },
     377             :     { "ooxml-squareTabs", "squareTabs" },
     378             :     { "ooxml-leftRightUpArrow", "leftRightUpArrow" },
     379             :     { "ooxml-homePlate", "homePlate" },
     380             :     { "ooxml-dodecagon", "dodecagon" },
     381             :     { "ooxml-leftArrowCallout", "leftArrowCallout" },
     382             :     { "ooxml-chord", "chord" },
     383             :     { "ooxml-quadArrowCallout", "quadArrowCallout" },
     384             :     { "ooxml-actionButtonBeginning", "actionButtonBeginning" },
     385             :     { "ooxml-ellipse", "ellipse" },
     386             :     { "ooxml-actionButtonEnd", "actionButtonEnd" },
     387             :     { "ooxml-arc", "arc" },
     388             :     { "ooxml-star16", "star16" },
     389             :     { "ooxml-parallelogram", "parallelogram" },
     390             :     { "ooxml-bevel", "bevel" },
     391             :     { "ooxml-roundRect", "roundRect" },
     392             :     { "ooxml-accentCallout1", "accentCallout1" },
     393             :     { "ooxml-flowChartSort", "flowChartSort" },
     394             :     { "ooxml-star8", "star8" },
     395             :     { "ooxml-flowChartAlternateProcess", "flowChartAlternateProcess" },
     396             :     { "ooxml-moon", "moon" },
     397             :     { "ooxml-star6", "star6" },
     398             :     { "ooxml-round2SameRect", "round2SameRect" },
     399             :     { "ooxml-nonIsoscelesTrapezoid", "nonIsoscelesTrapezoid" },
     400             :     { "ooxml-diamond", "diamond" },
     401             :     { "ooxml-ellipseRibbon", "ellipseRibbon" },
     402             :     { "ooxml-callout2", "callout2" },
     403             :     { "ooxml-pie", "pie" },
     404             :     { "ooxml-star4", "star4" },
     405             :     { "ooxml-flowChartPredefinedProcess", "flowChartPredefinedProcess" },
     406             :     { "ooxml-flowChartPunchedTape", "flowChartPunchedTape" },
     407             :     { "ooxml-curvedConnector2", "curvedConnector2" },
     408             :     { "ooxml-bentConnector3", "bentConnector3" },
     409             :     { "ooxml-cornerTabs", "cornerTabs" },
     410             :     { "ooxml-hexagon", "hexagon" },
     411             :     { "ooxml-flowChartConnector", "flowChartConnector" },
     412             :     { "ooxml-flowChartMagneticDisk", "flowChartMagneticDisk" },
     413             :     { "ooxml-heart", "heart" },
     414             :     { "ooxml-ribbon2", "ribbon2" },
     415             :     { "ooxml-bracePair", "bracePair" },
     416             :     { "ooxml-flowChartExtract", "flowChartExtract" },
     417             :     { "ooxml-actionButtonHome", "actionButtonHome" },
     418             :     { "ooxml-accentBorderCallout3", "accentBorderCallout3" },
     419             :     { "ooxml-flowChartOfflineStorage", "flowChartOfflineStorage" },
     420             :     { "ooxml-irregularSeal1", "irregularSeal1" },
     421             :     { "ooxml-quadArrow", "quadArrow" },
     422             :     { "ooxml-leftBrace", "leftBrace" },
     423             :     { "ooxml-leftBracket", "leftBracket" },
     424             :     { "ooxml-blockArc", "blockArc" },
     425             :     { "ooxml-curvedConnector3", "curvedConnector3" },
     426             :     { "ooxml-wedgeRoundRectCallout", "wedgeRoundRectCallout" },
     427             :     { "ooxml-actionButtonMovie", "actionButtonMovie" },
     428             :     { "ooxml-flowChartOnlineStorage", "flowChartOnlineStorage" },
     429             :     { "ooxml-gear6", "gear6" },
     430             :     { "ooxml-halfFrame", "halfFrame" },
     431             :     { "ooxml-snip2SameRect", "snip2SameRect" },
     432             :     { "ooxml-triangle", "triangle" },
     433             :     { "ooxml-teardrop", "teardrop" },
     434             :     { "ooxml-flowChartDocument", "flowChartDocument" },
     435             :     { "ooxml-rightArrowCallout", "rightArrowCallout" },
     436             :     { "ooxml-rightBrace", "rightBrace" },
     437             :     { "ooxml-chartPlus", "chartPlus" },
     438             :     { "ooxml-flowChartManualInput", "flowChartManualInput" },
     439             :     { "ooxml-flowChartMerge", "flowChartMerge" },
     440             :     { "ooxml-line", "line" },
     441             :     { "ooxml-downArrow", "downArrow" },
     442             :     { "ooxml-curvedDownArrow", "curvedDownArrow" },
     443             :     { "ooxml-actionButtonReturn", "actionButtonReturn" },
     444             :     { "ooxml-flowChartInputOutput", "flowChartInputOutput" },
     445             :     { "ooxml-bracketPair", "bracketPair" },
     446             :     { "ooxml-smileyFace", "smileyFace" },
     447             :     { "ooxml-actionButtonBlank", "actionButtonBlank" },
     448             :     { "ooxml-wave", "wave" },
     449             :     { "ooxml-swooshArrow", "swooshArrow" },
     450             :     { "ooxml-flowChartSummingJunction", "flowChartSummingJunction" },
     451             :     { "ooxml-lightningBolt", "lightningBolt" },
     452             :     { "ooxml-flowChartDisplay", "flowChartDisplay" },
     453             :     { "ooxml-actionButtonBackPrevious", "actionButtonBackPrevious" },
     454             :     { "ooxml-frame", "frame" },
     455             :     { "ooxml-rtTriangle", "rtTriangle" },
     456             :     { "ooxml-flowChartMagneticTape", "flowChartMagneticTape" },
     457             :     { "ooxml-curvedRightArrow", "curvedRightArrow" },
     458             :     { "ooxml-leftUpArrow", "leftUpArrow" },
     459             :     { "ooxml-wedgeEllipseCallout", "wedgeEllipseCallout" },
     460             :     { "ooxml-doubleWave", "doubleWave" },
     461             :     { "ooxml-bentArrow", "bentArrow" },
     462             :     { "ooxml-star10", "star10" },
     463             :     { "ooxml-leftArrow", "leftArrow" },
     464             :     { "ooxml-curvedUpArrow", "curvedUpArrow" },
     465             :     { "ooxml-snip1Rect", "snip1Rect" },
     466             :     { "ooxml-ellipseRibbon2", "ellipseRibbon2" },
     467             :     { "ooxml-plus", "plus" },
     468             :     { "ooxml-accentCallout3", "accentCallout3" },
     469             :     { "ooxml-leftCircularArrow", "leftCircularArrow" },
     470             :     { "ooxml-rightArrow", "rightArrow" },
     471             :     { "ooxml-flowChartPunchedCard", "flowChartPunchedCard" },
     472             :     { "ooxml-snip2DiagRect", "snip2DiagRect" },
     473             :     { "ooxml-verticalScroll", "verticalScroll" },
     474             :     { "ooxml-star7", "star7" },
     475             :     { "ooxml-chartX", "chartX" },
     476             :     { "ooxml-cloud", "cloud" },
     477             :     { "ooxml-cube", "cube" },
     478             :     { "ooxml-round2DiagRect", "round2DiagRect" },
     479             :     { "ooxml-flowChartMultidocument", "flowChartMultidocument" },
     480             :     { "ooxml-actionButtonDocument", "actionButtonDocument" },
     481             :     { "ooxml-flowChartTerminator", "flowChartTerminator" },
     482             :     { "ooxml-flowChartDelay", "flowChartDelay" },
     483             :     { "ooxml-curvedConnector5", "curvedConnector5" },
     484             :     { "ooxml-horizontalScroll", "horizontalScroll" },
     485             :     { "ooxml-bentConnector4", "bentConnector4" },
     486             :     { "ooxml-leftRightCircularArrow", "leftRightCircularArrow" },
     487             :     { "ooxml-wedgeRectCallout", "wedgeRectCallout" },
     488             :     { "ooxml-accentCallout2", "accentCallout2" },
     489             :     { "ooxml-flowChartMagneticDrum", "flowChartMagneticDrum" },
     490             :     { "ooxml-corner", "corner" },
     491             :     { "ooxml-borderCallout2", "borderCallout2" },
     492             :     { "ooxml-donut", "donut" },
     493             :     { "ooxml-flowChartCollate", "flowChartCollate" },
     494             :     { "ooxml-mathNotEqual", "mathNotEqual" },
     495             :     { "ooxml-bentConnector2", "bentConnector2" },
     496             :     { "ooxml-mathMultiply", "mathMultiply" },
     497             :     { "ooxml-heptagon", "heptagon" },
     498             :     { "ooxml-rect", "rect" },
     499             :     { "ooxml-accentBorderCallout2", "accentBorderCallout2" },
     500             :     { "ooxml-pieWedge", "pieWedge" },
     501             :     { "ooxml-upArrowCallout", "upArrowCallout" },
     502             :     { "ooxml-flowChartProcess", "flowChartProcess" },
     503             :     { "ooxml-star5", "star5" },
     504             :     { "ooxml-lineInv", "lineInv" },
     505             :     { "ooxml-straightConnector1", "straightConnector1" },
     506             :     { "ooxml-stripedRightArrow", "stripedRightArrow" },
     507             :     { "ooxml-callout3", "callout3" },
     508             :     { "ooxml-bentUpArrow", "bentUpArrow" },
     509             :     { "ooxml-noSmoking", "noSmoking" },
     510             :     { "ooxml-trapezoid", "trapezoid" },
     511             :     { "ooxml-cloudCallout", "cloudCallout" },
     512             :     { "ooxml-callout1", "callout1" },
     513             :     { "ooxml-ribbon", "ribbon" },
     514             : };
     515             : 
     516             : struct StringHash
     517             : {
     518           0 :     size_t operator()( const char* s ) const
     519             :     {
     520           0 :         return rtl_str_hashCode(s);
     521             :     }
     522             : };
     523             : 
     524             : struct StringCheck
     525             : {
     526           0 :     bool operator()( const char* s1, const char* s2 ) const
     527             :     {
     528           0 :         return strcmp( s1, s2 ) == 0;
     529             :     }
     530             : };
     531             : 
     532             : typedef boost::unordered_map< const char*, const char*, StringHash, StringCheck> CustomShapeTypeTranslationHashMap;
     533             : static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL;
     534             : 
     535           0 : static const char* lcl_GetPresetGeometry( const char* sShapeType )
     536             : {
     537             :     const char* sPresetGeo;
     538             : 
     539           0 :     if( pCustomShapeTypeTranslationHashMap == NULL )
     540             :     {
     541           0 :         pCustomShapeTypeTranslationHashMap = new CustomShapeTypeTranslationHashMap ();
     542           0 :         for( unsigned int i = 0; i < sizeof( pCustomShapeTypeTranslationTable )/sizeof( CustomShapeTypeTranslationTable ); i ++ )
     543             :         {
     544           0 :             (*pCustomShapeTypeTranslationHashMap)[ pCustomShapeTypeTranslationTable[ i ].sOOo ] = pCustomShapeTypeTranslationTable[ i ].sMSO;
     545             :             //DBG(printf("type OOo: %s MSO: %s\n", pCustomShapeTypeTranslationTable[ i ].sOOo, pCustomShapeTypeTranslationTable[ i ].sMSO));
     546             :         }
     547             :     }
     548             : 
     549           0 :     sPresetGeo = (*pCustomShapeTypeTranslationHashMap)[ sShapeType ];
     550             : 
     551           0 :     if( sPresetGeo == NULL )
     552           0 :         sPresetGeo = "rect";
     553             : 
     554           0 :     return sPresetGeo;
     555             : }
     556             : 
     557             : namespace oox { namespace drawingml {
     558             : 
     559             : #define GETA(propName) \
     560             :     GetProperty( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ) )
     561             : 
     562             : #define GETAD(propName) \
     563             :     ( GetPropertyAndState( rXPropSet, rXPropState, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ), eState ) && eState == beans::PropertyState_DIRECT_VALUE )
     564             : 
     565             : #define GET(variable, propName) \
     566             :     if ( GETA(propName) ) \
     567             :         mAny >>= variable;
     568             : 
     569             : // not thread safe
     570             : int ShapeExport::mnSpreadsheetCounter = 1;
     571             : 
     572           0 : ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap* pShapeMap, XmlFilterBase* pFB, DocumentType eDocumentType )
     573             :     : DrawingML( pFS, pFB, eDocumentType )
     574             :     , mnShapeIdMax( 1 )
     575             :     , mnPictureIdMax( 1 )
     576             :     , mnXmlNamespace( nXmlNamespace )
     577             :     , maFraction( 1, 576 )
     578             :     , maMapModeSrc( MAP_100TH_MM )
     579             :     , maMapModeDest( MAP_INCH, Point(), maFraction, maFraction )
     580           0 :     , mpShapeMap( pShapeMap ? pShapeMap : &maShapeMap )
     581             : {
     582           0 : }
     583             : 
     584           0 : awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const
     585             : {
     586           0 :     Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
     587             : 
     588           0 :     if ( !aRetSize.Width() )
     589           0 :         aRetSize.Width()++;
     590           0 :     if ( !aRetSize.Height() )
     591           0 :         aRetSize.Height()++;
     592           0 :     return awt::Size( aRetSize.Width(), aRetSize.Height() );
     593             : }
     594             : 
     595           0 : sal_Bool ShapeExport::NonEmptyText( Reference< XInterface > xIface )
     596             : {
     597           0 :     Reference< XPropertySet > xPropSet( xIface, UNO_QUERY );
     598             : 
     599           0 :     if( xPropSet.is() )
     600             :     {
     601           0 :         Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
     602           0 :         if ( xPropSetInfo.is() )
     603             :         {
     604           0 :             if ( xPropSetInfo->hasPropertyByName( S( "IsEmptyPresentationObject" ) ) )
     605             :             {
     606           0 :                 sal_Bool bIsEmptyPresObj = sal_False;
     607           0 :                 if ( xPropSet->getPropertyValue( S( "IsEmptyPresentationObject" ) ) >>= bIsEmptyPresObj )
     608             :                 {
     609             :                     DBG(printf("empty presentation object %d, props:\n", bIsEmptyPresObj));
     610           0 :                     if( bIsEmptyPresObj )
     611           0 :                        return sal_True;
     612             :                 }
     613             :             }
     614             : 
     615           0 :             if ( xPropSetInfo->hasPropertyByName( S( "IsPresentationObject" ) ) )
     616             :             {
     617           0 :                 sal_Bool bIsPresObj = sal_False;
     618           0 :                 if ( xPropSet->getPropertyValue( S( "IsPresentationObject" ) ) >>= bIsPresObj )
     619             :                 {
     620             :                     DBG(printf("presentation object %d, props:\n", bIsPresObj));
     621           0 :                     if( bIsPresObj )
     622           0 :                        return sal_True;
     623             :                 }
     624             :             }
     625           0 :         }
     626             :     }
     627             : 
     628           0 :     Reference< XSimpleText > xText( xIface, UNO_QUERY );
     629             : 
     630           0 :     if( xText.is() )
     631           0 :         return xText->getString().getLength();
     632             : 
     633           0 :     return sal_False;
     634             : }
     635             : 
     636           0 : ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool bClosed )
     637             : {
     638             :     DBG(printf("write open bezier shape\n"));
     639             : 
     640           0 :     FSHelperPtr pFS = GetFS();
     641           0 :     pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
     642             : 
     643           0 :     PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
     644           0 :     Rectangle aRect( aPolyPolygon.GetBoundRect() );
     645             : 
     646             : #if OSL_DEBUG_LEVEL > 0
     647             :     awt::Size size = MapSize( awt::Size( aRect.GetWidth(), aRect.GetHeight() ) );
     648             :     DBG(printf("poly count %d\nsize: %d x %d", aPolyPolygon.Count(), int( size.Width ), int( size.Height )));
     649             : #endif
     650             : 
     651             :     // non visual shape properties
     652           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
     653             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
     654             :                           XML_id, I32S( GetNewShapeID( xShape ) ),
     655           0 :                           XML_name, IDS( Freeform ),
     656           0 :                           FSEND );
     657           0 :     pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
     658           0 :     WriteNonVisualProperties( xShape );
     659           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
     660             : 
     661             :     // visual shape properties
     662           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
     663           0 :     WriteTransformation( aRect, XML_a );
     664           0 :     WritePolyPolygon( aPolyPolygon );
     665           0 :     Reference< XPropertySet > xProps( xShape, UNO_QUERY );
     666           0 :     if( xProps.is() ) {
     667           0 :         if( bClosed )
     668           0 :             WriteFill( xProps );
     669           0 :         WriteOutline( xProps );
     670             :     }
     671             : 
     672           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
     673             : 
     674             :     // write text
     675           0 :     WriteTextBox( xShape, mnXmlNamespace );
     676             : 
     677           0 :     pFS->endElementNS( mnXmlNamespace, XML_sp );
     678             : 
     679           0 :     return *this;
     680             : }
     681             : 
     682           0 : ShapeExport& ShapeExport::WriteClosedBezierShape( Reference< XShape > xShape )
     683             : {
     684           0 :     return WriteBezierShape( xShape, sal_True );
     685             : }
     686             : 
     687           0 : ShapeExport& ShapeExport::WriteOpenBezierShape( Reference< XShape > xShape )
     688             : {
     689           0 :     return WriteBezierShape( xShape, sal_False );
     690             : }
     691             : 
     692           0 : ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
     693             : {
     694             :     DBG(printf("write custom shape\n"));
     695             : 
     696           0 :     Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
     697           0 :     SdrObjCustomShape* pShape = (SdrObjCustomShape*) GetSdrObjectFromXShape( xShape );
     698           0 :     sal_Bool bIsDefaultObject = EscherPropertyContainer::IsDefaultObject( pShape );
     699           0 :     sal_Bool bPredefinedHandlesUsed = sal_True;
     700           0 :     OUString sShapeType;
     701           0 :     sal_uInt32 nMirrorFlags = 0;
     702           0 :     MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType( xShape, nMirrorFlags, sShapeType );
     703           0 :     const char* sPresetShape = lcl_GetPresetGeometry( USS( sShapeType ) );
     704             :     DBG(printf("custom shape type: %s ==> %s\n", USS( sShapeType ), sPresetShape));
     705           0 :     Sequence< PropertyValue > aGeometrySeq;
     706           0 :     sal_Int32 nAdjustmentValuesIndex = -1;
     707             : 
     708           0 :     sal_Bool bFlipH = false;
     709           0 :     sal_Bool bFlipV = false;
     710             : 
     711           0 :     if( GETA( CustomShapeGeometry ) ) {
     712             :         DBG(printf("got custom shape geometry\n"));
     713           0 :         if( mAny >>= aGeometrySeq ) {
     714             : 
     715             :             DBG(printf("got custom shape geometry sequence\n"));
     716           0 :             for( int i = 0; i < aGeometrySeq.getLength(); i++ ) {
     717           0 :                 const PropertyValue& rProp = aGeometrySeq[ i ];
     718             :                 DBG(printf("geometry property: %s\n", USS( rProp.Name )));
     719             : 
     720           0 :                 if ( rProp.Name == "MirroredX" )
     721           0 :                     rProp.Value >>= bFlipH;
     722             : 
     723           0 :                 if ( rProp.Name == "MirroredY" )
     724           0 :                     rProp.Value >>= bFlipV;
     725           0 :                 if ( rProp.Name == "AdjustmentValues" )
     726           0 :                     nAdjustmentValuesIndex = i;
     727           0 :                 else if ( rProp.Name == "Handles" ) {
     728           0 :                     if( !bIsDefaultObject )
     729           0 :                         bPredefinedHandlesUsed = sal_False;
     730             :                     // TODO: update nAdjustmentsWhichNeedsToBeConverted here
     731             :                 }
     732             :             }
     733             :         }
     734             :     }
     735             : 
     736           0 :     FSHelperPtr pFS = GetFS();
     737           0 :     pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
     738             : 
     739             :     // non visual shape properties
     740           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
     741             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
     742             :                           XML_id, I32S( GetNewShapeID( xShape ) ),
     743           0 :                           XML_name, IDS( CustomShape ),
     744           0 :                           FSEND );
     745           0 :     pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
     746           0 :     WriteNonVisualProperties( xShape );
     747           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
     748             : 
     749             :     // visual shape properties
     750           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
     751           0 :     WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, false);
     752           0 :     if( nAdjustmentValuesIndex != -1 )
     753             :     {
     754           0 :         sal_Int32 nAdjustmentsWhichNeedsToBeConverted = 0;
     755             :         WritePresetShape( sPresetShape, eShapeType, bPredefinedHandlesUsed,
     756           0 :                           nAdjustmentsWhichNeedsToBeConverted, aGeometrySeq[ nAdjustmentValuesIndex ] );
     757             :     }
     758             :     else
     759           0 :         WritePresetShape( sPresetShape );
     760           0 :     if( rXPropSet.is() )
     761             :     {
     762           0 :         WriteFill( rXPropSet );
     763           0 :         WriteOutline( rXPropSet );
     764             :     }
     765             : 
     766           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
     767             : 
     768             :     // write text
     769           0 :     WriteTextBox( xShape, mnXmlNamespace );
     770             : 
     771           0 :     pFS->endElementNS( mnXmlNamespace, XML_sp );
     772             : 
     773           0 :     return *this;
     774             : }
     775             : 
     776           0 : ShapeExport& ShapeExport::WriteEllipseShape( Reference< XShape > xShape )
     777             : {
     778             :     DBG(printf("write ellipse shape\n"));
     779             : 
     780           0 :     FSHelperPtr pFS = GetFS();
     781             : 
     782           0 :     pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
     783             : 
     784             :     // TODO: arc, section, cut, connector
     785             : 
     786             :     // non visual shape properties
     787           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
     788             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
     789             :                           XML_id, I32S( GetNewShapeID( xShape ) ),
     790           0 :                           XML_name, IDS( Ellipse ),
     791           0 :                           FSEND );
     792           0 :     pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
     793           0 :     WriteNonVisualProperties( xShape );
     794           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
     795             : 
     796             :     // visual shape properties
     797           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
     798           0 :     WriteShapeTransformation( xShape, XML_a,0,0,false);
     799           0 :     WritePresetShape( "ellipse" );
     800           0 :     Reference< XPropertySet > xProps( xShape, UNO_QUERY );
     801           0 :     if( xProps.is() )
     802             :     {
     803           0 :         WriteFill( xProps );
     804           0 :         WriteOutline( xProps );
     805             :     }
     806           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
     807             : 
     808             :     // write text
     809           0 :     WriteTextBox( xShape, mnXmlNamespace );
     810             : 
     811           0 :     pFS->endElementNS( mnXmlNamespace, XML_sp );
     812             : 
     813           0 :     return *this;
     814             : }
     815             : 
     816           0 : ShapeExport& ShapeExport::WriteGraphicObjectShape( Reference< XShape > xShape )
     817             : {
     818           0 :     WriteGraphicObjectShapePart( xShape );
     819             : 
     820           0 :     return *this;
     821             : }
     822             : 
     823           0 : void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, Graphic* pGraphic )
     824             : {
     825             :     DBG(printf("write graphic object shape\n"));
     826             : 
     827           0 :     if( NonEmptyText( xShape ) )
     828             :     {
     829           0 :         WriteTextShape( xShape );
     830             : 
     831             :         //DBG(dump_pset(mXPropSet));
     832             : 
     833             :         return;
     834             :     }
     835             : 
     836             :     DBG(printf("graphicObject without text\n"));
     837             : 
     838           0 :     OUString sGraphicURL;
     839           0 :     Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
     840           0 :     if( !pGraphic && ( !xShapeProps.is() || !( xShapeProps->getPropertyValue( S( "GraphicURL" ) ) >>= sGraphicURL ) ) )
     841             :     {
     842             :         DBG(printf("no graphic URL found\n"));
     843             :         return;
     844             :     }
     845             : 
     846           0 :     FSHelperPtr pFS = GetFS();
     847             : 
     848           0 :     pFS->startElementNS( mnXmlNamespace, XML_pic, FSEND );
     849             : 
     850           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvPicPr, FSEND );
     851             : 
     852           0 :     OUString sName, sDescr;
     853             :     bool bHaveName, bHaveDesc;
     854             : 
     855           0 :     if ( ( bHaveName= GetProperty( xShapeProps, S( "Name" ) ) ) )
     856           0 :         mAny >>= sName;
     857           0 :     if ( ( bHaveDesc = GetProperty( xShapeProps, S( "Description" ) ) ) )
     858           0 :         mAny >>= sDescr;
     859             : 
     860             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
     861             :                           XML_id,     I32S( GetNewShapeID( xShape ) ),
     862           0 :                           XML_name,   bHaveName ? USS( sName ) : OString( "Picture " + OString::valueOf( mnPictureIdMax++ )).getStr(),
     863           0 :                           XML_descr,  bHaveDesc ? USS( sDescr ) : NULL,
     864           0 :                           FSEND );
     865             :     // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkClick, XML_hlinkHover
     866             : 
     867             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPicPr,
     868             :                           // OOXTODO: XML_preferRelativeSize
     869           0 :                           FSEND );
     870             : 
     871           0 :     WriteNonVisualProperties( xShape );
     872             : 
     873           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvPicPr );
     874             : 
     875           0 :     pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND );
     876             : 
     877           0 :     WriteBlip( xShapeProps, sGraphicURL, pGraphic );
     878             : 
     879             :     // now we stretch always when we get pGraphic (when changing that
     880             :     // behavior, test n#780830 for regression, where the OLE sheet might get tiled
     881           0 :     bool bStretch = false;
     882           0 :     if( !pGraphic && GetProperty( xShapeProps, S( "FillBitmapStretch" ) ) )
     883           0 :         mAny >>= bStretch;
     884             : 
     885           0 :     if ( pGraphic || bStretch )
     886           0 :         WriteStretch();
     887             : 
     888           0 :     pFS->endElementNS( mnXmlNamespace, XML_blipFill );
     889             : 
     890             :     // visual shape properties
     891           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
     892           0 :     WriteShapeTransformation( xShape, XML_a,0,0,false);
     893           0 :     WritePresetShape( "rect" );
     894             :     // graphic object can come with the frame (bnc#654525)
     895           0 :     WriteOutline( xShapeProps );
     896           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
     897             : 
     898           0 :     pFS->endElementNS( mnXmlNamespace, XML_pic );
     899             : }
     900             : 
     901           0 : ShapeExport& ShapeExport::WriteConnectorShape( Reference< XShape > xShape )
     902             : {
     903           0 :     sal_Bool bFlipH = false;
     904           0 :     sal_Bool bFlipV = false;
     905             : 
     906             :     DBG(printf("write connector shape\n"));
     907             : 
     908           0 :     FSHelperPtr pFS = GetFS();
     909             : 
     910           0 :     const char* sGeometry = "line";
     911           0 :     Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
     912           0 :     Reference< XPropertyState > rXPropState( xShape, UNO_QUERY );
     913           0 :     awt::Point aStartPoint, aEndPoint;
     914           0 :     Reference< XShape > rXShapeA;
     915           0 :     Reference< XShape > rXShapeB;
     916             :     PropertyState eState;
     917             :     ConnectorType eConnectorType;
     918           0 :     if( GETAD( EdgeKind ) ) {
     919           0 :         mAny >>= eConnectorType;
     920             : 
     921           0 :         switch( eConnectorType ) {
     922             :             case ConnectorType_CURVE:
     923           0 :                 sGeometry = "curvedConnector3";
     924           0 :                 break;
     925             :             case ConnectorType_STANDARD:
     926           0 :                 sGeometry = "bentConnector3";
     927           0 :                 break;
     928             :             default:
     929             :             case ConnectorType_LINE:
     930             :             case ConnectorType_LINES:
     931           0 :                 sGeometry = "straightConnector1";
     932           0 :                 break;
     933             :         }
     934             : 
     935           0 :         if( GETAD( EdgeStartPoint ) ) {
     936           0 :             mAny >>= aStartPoint;
     937           0 :             if( GETAD( EdgeEndPoint ) ) {
     938           0 :                 mAny >>= aEndPoint;
     939             :             }
     940             :         }
     941           0 :         GET( rXShapeA, EdgeStartConnection );
     942           0 :         GET( rXShapeB, EdgeEndConnection );
     943             :     }
     944           0 :     EscherConnectorListEntry aConnectorEntry( xShape, aStartPoint, rXShapeA, aEndPoint, rXShapeB );
     945             : 
     946           0 :     Rectangle aRect( Point( aStartPoint.X, aStartPoint.Y ), Point( aEndPoint.X, aEndPoint.Y ) );
     947           0 :     if( aRect.getWidth() < 0 ) {
     948           0 :         bFlipH = sal_True;
     949           0 :         aRect.setX( aEndPoint.X );
     950           0 :         aRect.setWidth( aStartPoint.X - aEndPoint.X );
     951             :     }
     952             : 
     953           0 :     if( aRect.getHeight() < 0 ) {
     954           0 :         bFlipV = sal_True;
     955           0 :         aRect.setY( aEndPoint.Y );
     956           0 :         aRect.setHeight( aStartPoint.Y - aEndPoint.Y );
     957             :     }
     958             : 
     959           0 :     pFS->startElementNS( mnXmlNamespace, XML_cxnSp, FSEND );
     960             : 
     961             :     // non visual shape properties
     962           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvCxnSpPr, FSEND );
     963             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
     964             :                           XML_id, I32S( GetNewShapeID( xShape ) ),
     965           0 :                           XML_name, IDS( Line ),
     966           0 :                           FSEND );
     967             :     // non visual connector shape drawing properties
     968           0 :     pFS->startElementNS( mnXmlNamespace, XML_cNvCxnSpPr, FSEND );
     969           0 :     WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), GetShapeID( rXShapeB ) );
     970           0 :     pFS->endElementNS( mnXmlNamespace, XML_cNvCxnSpPr );
     971           0 :     pFS->singleElementNS( mnXmlNamespace, XML_nvPr, FSEND );
     972           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvCxnSpPr );
     973             : 
     974             :     // visual shape properties
     975           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
     976           0 :     WriteTransformation( aRect, XML_a, bFlipH, bFlipV );
     977             :     // TODO: write adjustments (ppt export doesn't work well there either)
     978           0 :     WritePresetShape( sGeometry );
     979           0 :     Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
     980           0 :     if( xShapeProps.is() )
     981           0 :         WriteOutline( xShapeProps );
     982           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
     983             : 
     984             :     // write text
     985           0 :     WriteTextBox( xShape, mnXmlNamespace );
     986             : 
     987           0 :     pFS->endElementNS( mnXmlNamespace, XML_cxnSp );
     988             : 
     989           0 :     return *this;
     990             : }
     991             : 
     992           0 : ShapeExport& ShapeExport::WriteLineShape( Reference< XShape > xShape )
     993             : {
     994           0 :     sal_Bool bFlipH = false;
     995           0 :     sal_Bool bFlipV = false;
     996             : 
     997             :     DBG(printf("write line shape\n"));
     998             : 
     999           0 :     FSHelperPtr pFS = GetFS();
    1000             : 
    1001           0 :     pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
    1002             : 
    1003           0 :     PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
    1004           0 :     if( aPolyPolygon.Count() == 1 && aPolyPolygon[ 0 ].GetSize() == 2)
    1005             :     {
    1006           0 :         const Polygon& rPoly = aPolyPolygon[ 0 ];
    1007             : 
    1008           0 :         bFlipH = ( rPoly[ 0 ].X() > rPoly[ 1 ].X() );
    1009           0 :         bFlipV = ( rPoly[ 0 ].Y() > rPoly[ 1 ].Y() );
    1010             :     }
    1011             : 
    1012             :     // non visual shape properties
    1013           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
    1014             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
    1015             :                           XML_id, I32S( GetNewShapeID( xShape ) ),
    1016           0 :                           XML_name, IDS( Line ),
    1017           0 :                           FSEND );
    1018           0 :     pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
    1019           0 :     WriteNonVisualProperties( xShape );
    1020           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
    1021             : 
    1022             :     // visual shape properties
    1023           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
    1024           0 :     WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, true);
    1025           0 :     WritePresetShape( "line" );
    1026           0 :     Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
    1027           0 :     if( xShapeProps.is() )
    1028           0 :         WriteOutline( xShapeProps );
    1029           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
    1030             : 
    1031             :     // write text
    1032           0 :     WriteTextBox( xShape, mnXmlNamespace );
    1033             : 
    1034           0 :     pFS->endElementNS( mnXmlNamespace, XML_sp );
    1035             : 
    1036           0 :     return *this;
    1037             : }
    1038             : 
    1039           0 : ShapeExport& ShapeExport::WriteNonVisualDrawingProperties( Reference< XShape > xShape, const char* pName )
    1040             : {
    1041             :     GetFS()->singleElementNS( mnXmlNamespace, XML_cNvPr,
    1042             :                               XML_id, I32S( GetNewShapeID( xShape ) ),
    1043             :                               XML_name, pName,
    1044           0 :                               FSEND );
    1045             : 
    1046           0 :     return *this;
    1047             : }
    1048             : 
    1049           0 : ShapeExport& ShapeExport::WriteNonVisualProperties( Reference< XShape > )
    1050             : {
    1051             :     // Override to generate //nvPr elements.
    1052           0 :     return *this;
    1053             : }
    1054             : 
    1055           0 : ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape )
    1056             : {
    1057             :     DBG(printf("write rectangle shape\n"));
    1058             : 
    1059           0 :     FSHelperPtr pFS = GetFS();
    1060             : 
    1061           0 :     pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
    1062             : 
    1063           0 :     sal_Int32 nRadius = 0;
    1064             : 
    1065           0 :     Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
    1066           0 :     if( xShapeProps.is() )
    1067             :     {
    1068           0 :         xShapeProps->getPropertyValue( S( "CornerRadius" ) ) >>= nRadius;
    1069             :     }
    1070             : 
    1071           0 :     if( nRadius )
    1072             :     {
    1073           0 :         nRadius = MapSize( awt::Size( nRadius, 0 ) ).Width;
    1074             :     }
    1075             : 
    1076             :     // non visual shape properties
    1077           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
    1078             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
    1079             :                           XML_id, I32S( GetNewShapeID( xShape ) ),
    1080           0 :                           XML_name, IDS( Rectangle ),
    1081           0 :                           FSEND );
    1082           0 :     pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
    1083           0 :     WriteNonVisualProperties( xShape );
    1084           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
    1085             : 
    1086             :     // visual shape properties
    1087           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
    1088           0 :     WriteShapeTransformation( xShape, XML_a,0,0,false);
    1089           0 :     WritePresetShape( "rect" );
    1090           0 :     Reference< XPropertySet > xProps( xShape, UNO_QUERY );
    1091           0 :     if( xProps.is() )
    1092             :     {
    1093           0 :         WriteFill( xProps );
    1094           0 :         WriteOutline( xProps );
    1095             :     }
    1096           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
    1097             : 
    1098             :     // write text
    1099           0 :     WriteTextBox( xShape, mnXmlNamespace );
    1100             : 
    1101           0 :     pFS->endElementNS( mnXmlNamespace, XML_sp );
    1102             : 
    1103           0 :     return *this;
    1104             : }
    1105             : 
    1106             : typedef ShapeExport& (ShapeExport::*ShapeConverter)( Reference< XShape > );
    1107             : typedef boost::unordered_map< const char*, ShapeConverter, StringHash, StringCheck> NameToConvertMapType;
    1108             : 
    1109           0 : static const NameToConvertMapType& lcl_GetConverters()
    1110             : {
    1111             :     static bool shape_map_inited = false;
    1112           0 :     static NameToConvertMapType shape_converters;
    1113           0 :     if( shape_map_inited )
    1114             :     {
    1115           0 :         return shape_converters;
    1116             :     }
    1117             : 
    1118           0 :     shape_converters[ "com.sun.star.drawing.ClosedBezierShape" ]        = &ShapeExport::WriteClosedBezierShape;
    1119           0 :     shape_converters[ "com.sun.star.drawing.ConnectorShape" ]           = &ShapeExport::WriteConnectorShape;
    1120           0 :     shape_converters[ "com.sun.star.drawing.CustomShape" ]              = &ShapeExport::WriteCustomShape;
    1121           0 :     shape_converters[ "com.sun.star.drawing.EllipseShape" ]             = &ShapeExport::WriteEllipseShape;
    1122           0 :     shape_converters[ "com.sun.star.drawing.GraphicObjectShape" ]       = &ShapeExport::WriteGraphicObjectShape;
    1123           0 :     shape_converters[ "com.sun.star.drawing.LineShape" ]                = &ShapeExport::WriteLineShape;
    1124           0 :     shape_converters[ "com.sun.star.drawing.OpenBezierShape" ]          = &ShapeExport::WriteOpenBezierShape;
    1125           0 :     shape_converters[ "com.sun.star.drawing.RectangleShape" ]           = &ShapeExport::WriteRectangleShape;
    1126           0 :     shape_converters[ "com.sun.star.drawing.OLE2Shape" ]                = &ShapeExport::WriteOLE2Shape;
    1127           0 :     shape_converters[ "com.sun.star.drawing.TableShape" ]               = &ShapeExport::WriteTableShape;
    1128           0 :     shape_converters[ "com.sun.star.drawing.TextShape" ]                = &ShapeExport::WriteTextShape;
    1129           0 :     shape_converters[ "com.sun.star.presentation.DateTimeShape" ]       = &ShapeExport::WriteTextShape;
    1130           0 :     shape_converters[ "com.sun.star.presentation.FooterShape" ]         = &ShapeExport::WriteTextShape;
    1131           0 :     shape_converters[ "com.sun.star.presentation.HeaderShape" ]         = &ShapeExport::WriteTextShape;
    1132           0 :     shape_converters[ "com.sun.star.presentation.NotesShape" ]          = &ShapeExport::WriteTextShape;
    1133           0 :     shape_converters[ "com.sun.star.presentation.OutlinerShape" ]       = &ShapeExport::WriteTextShape;
    1134           0 :     shape_converters[ "com.sun.star.presentation.SlideNumberShape" ]    = &ShapeExport::WriteTextShape;
    1135           0 :     shape_converters[ "com.sun.star.presentation.TitleTextShape" ]      = &ShapeExport::WriteTextShape;
    1136           0 :     shape_map_inited = true;
    1137             : 
    1138           0 :     return shape_converters;
    1139             : }
    1140             : 
    1141           0 : ShapeExport& ShapeExport::WriteShape( Reference< XShape > xShape )
    1142             : {
    1143           0 :     OUString sShapeType = xShape->getShapeType();
    1144             :     DBG( printf( "write shape: %s\n", USS( sShapeType ) ) );
    1145           0 :     NameToConvertMapType::const_iterator aConverter = lcl_GetConverters().find( USS( sShapeType ) );
    1146           0 :     if( aConverter == lcl_GetConverters().end() )
    1147             :     {
    1148             :         DBG( printf( "unknown shape\n" ) );
    1149           0 :         return WriteUnknownShape( xShape );
    1150             :     }
    1151           0 :     (this->*(aConverter->second))( xShape );
    1152             : 
    1153           0 :     return *this;
    1154             : }
    1155             : 
    1156           0 : ShapeExport& ShapeExport::WriteTextBox( Reference< XInterface > xIface, sal_Int32 nXmlNamespace )
    1157             : {
    1158           0 :     if( NonEmptyText( xIface ) )
    1159             :     {
    1160           0 :         FSHelperPtr pFS = GetFS();
    1161             : 
    1162           0 :         pFS->startElementNS( nXmlNamespace, XML_txBody, FSEND );
    1163           0 :         WriteText( xIface );
    1164           0 :         pFS->endElementNS( nXmlNamespace, XML_txBody );
    1165             :     }
    1166             : 
    1167           0 :     return *this;
    1168             : }
    1169             : 
    1170           0 : void ShapeExport::WriteTable( Reference< XShape > rXShape  )
    1171             : {
    1172             :     OSL_TRACE("write table");
    1173             : 
    1174           0 :     Reference< XTable > xTable;
    1175           0 :     Reference< XPropertySet > xPropSet( rXShape, UNO_QUERY );
    1176             : 
    1177           0 :     mpFS->startElementNS( XML_a, XML_graphic, FSEND );
    1178           0 :     mpFS->startElementNS( XML_a, XML_graphicData, XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/table", FSEND );
    1179             : 
    1180           0 :     if ( xPropSet.is() && ( xPropSet->getPropertyValue( S("Model") ) >>= xTable ) )
    1181             :     {
    1182           0 :         mpFS->startElementNS( XML_a, XML_tbl, FSEND );
    1183           0 :         mpFS->singleElementNS( XML_a, XML_tblPr, FSEND );
    1184             : 
    1185           0 :         Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW );
    1186           0 :         Reference< container::XIndexAccess > xColumns( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
    1187           0 :         Reference< container::XIndexAccess > xRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
    1188           0 :         sal_uInt16 nRowCount = static_cast< sal_uInt16 >( xRows->getCount() );
    1189           0 :         sal_uInt16 nColumnCount = static_cast< sal_uInt16 >( xColumns->getCount() );
    1190             : 
    1191           0 :         mpFS->startElementNS( XML_a, XML_tblGrid, FSEND );
    1192             : 
    1193           0 :         for ( sal_Int32 x = 0; x < nColumnCount; x++ )
    1194             :         {
    1195           0 :             Reference< XPropertySet > xColPropSet( xColumns->getByIndex( x ), UNO_QUERY_THROW );
    1196           0 :             sal_Int32 nWidth(0);
    1197           0 :             xColPropSet->getPropertyValue( S("Width") ) >>= nWidth;
    1198             : 
    1199           0 :             mpFS->singleElementNS( XML_a, XML_gridCol, XML_w, I64S(MM100toEMU(nWidth)), FSEND );
    1200           0 :         }
    1201             : 
    1202           0 :         mpFS->endElementNS( XML_a, XML_tblGrid );
    1203             : 
    1204           0 :         Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
    1205           0 :         for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
    1206             :         {
    1207           0 :             Reference< XPropertySet > xRowPropSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
    1208           0 :             sal_Int32 nRowHeight(0);
    1209             : 
    1210           0 :             xRowPropSet->getPropertyValue( S("Height") ) >>= nRowHeight;
    1211             : 
    1212           0 :             mpFS->startElementNS( XML_a, XML_tr, XML_h, I64S( MM100toEMU( nRowHeight ) ), FSEND );
    1213             : 
    1214           0 :             for( sal_Int32 nColumn = 0; nColumn < nColumnCount; nColumn++ )
    1215             :             {
    1216           0 :                 Reference< XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ), UNO_QUERY_THROW );
    1217           0 :                 if ( !xCell->isMerged() )
    1218             :                 {
    1219           0 :                     mpFS->startElementNS( XML_a, XML_tc, FSEND );
    1220             : 
    1221           0 :                     WriteTextBox( xCell, XML_a );
    1222             : 
    1223           0 :                     mpFS->singleElementNS( XML_a, XML_tcPr, FSEND );
    1224           0 :                     mpFS->endElementNS( XML_a, XML_tc );
    1225             :                 }
    1226           0 :             }
    1227             : 
    1228           0 :             mpFS->endElementNS( XML_a, XML_tr );
    1229           0 :         }
    1230             : 
    1231           0 :         mpFS->endElementNS( XML_a, XML_tbl );
    1232             :     }
    1233             : 
    1234           0 :     mpFS->endElementNS( XML_a, XML_graphicData );
    1235           0 :     mpFS->endElementNS( XML_a, XML_graphic );
    1236           0 : }
    1237             : 
    1238           0 : ShapeExport& ShapeExport::WriteTableShape( Reference< XShape > xShape )
    1239             : {
    1240           0 :     FSHelperPtr pFS = GetFS();
    1241             : 
    1242             :     OSL_TRACE("write table shape");
    1243             : 
    1244           0 :     pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
    1245             : 
    1246           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
    1247             : 
    1248             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
    1249             :                           XML_id,     I32S( GetNewShapeID( xShape ) ),
    1250           0 :                           XML_name,   IDS(Table),
    1251           0 :                           FSEND );
    1252             : 
    1253             :     pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
    1254           0 :                           FSEND );
    1255             : 
    1256           0 :     if( GetDocumentType() == DOCUMENT_PPTX )
    1257             :         pFS->singleElementNS( mnXmlNamespace, XML_nvPr,
    1258           0 :                           FSEND );
    1259           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
    1260             : 
    1261           0 :     WriteShapeTransformation( xShape, mnXmlNamespace, false);
    1262           0 :     WriteTable( xShape );
    1263             : 
    1264           0 :     pFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
    1265             : 
    1266           0 :     return *this;
    1267             : }
    1268             : 
    1269           0 : ShapeExport& ShapeExport::WriteTextShape( Reference< XShape > xShape )
    1270             : {
    1271           0 :     FSHelperPtr pFS = GetFS();
    1272             : 
    1273           0 :     pFS->startElementNS( mnXmlNamespace, XML_sp, FSEND );
    1274             : 
    1275             :     // non visual shape properties
    1276           0 :     pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
    1277           0 :     WriteNonVisualDrawingProperties( xShape, IDS( TextShape ) );
    1278           0 :     pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1", FSEND );
    1279           0 :     WriteNonVisualProperties( xShape );
    1280           0 :     pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
    1281             : 
    1282             :     // visual shape properties
    1283           0 :     pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
    1284           0 :     WriteShapeTransformation( xShape, XML_a,0,0,false);
    1285           0 :     WritePresetShape( "rect" );
    1286           0 :     WriteBlipFill( Reference< XPropertySet >(xShape, UNO_QUERY ), S( "GraphicURL" ) );
    1287           0 :     pFS->endElementNS( mnXmlNamespace, XML_spPr );
    1288             : 
    1289           0 :     WriteTextBox( xShape, mnXmlNamespace );
    1290             : 
    1291           0 :     pFS->endElementNS( mnXmlNamespace, XML_sp );
    1292             : 
    1293           0 :     return *this;
    1294             : }
    1295             : 
    1296           0 : ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape )
    1297             : {
    1298           0 :     Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
    1299           0 :     if( xPropSet.is() ) {
    1300           0 :         if( GetProperty( xPropSet, S("Model") ) )
    1301             :         {
    1302           0 :             Reference< XChartDocument > xChartDoc;
    1303           0 :             mAny >>= xChartDoc;
    1304           0 :             if( xChartDoc.is() )
    1305             :             {
    1306             :                 //export the chart
    1307           0 :                 Reference< XModel > xModel( xChartDoc, UNO_QUERY );
    1308           0 :                 ChartExport aChartExport( mnXmlNamespace, GetFS(), xModel, GetFB(), GetDocumentType() );
    1309             :                 static sal_Int32 nChartCount = 0;
    1310           0 :                 aChartExport.WriteChartObj( xShape, ++nChartCount );
    1311             :             }
    1312             :             else
    1313             :             {
    1314             :                 // this part now supports only embedded spreadsheets, it can be extended to support remaining ooxml documents
    1315             :                 // only exporter, counter and object filename are specific to spreadsheet
    1316           0 :                 Reference< XSpreadsheetDocument > xSheetDoc( mAny, UNO_QUERY );
    1317           0 :                 if( xSheetDoc.is() )
    1318             :                 {
    1319           0 :                     Reference< XComponent > xDocument( mAny, UNO_QUERY );
    1320           0 :                     Reference< XExporter > xExporter( mpFB->getServiceFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.comp.oox.ExcelFilterExport" ) ), UNO_QUERY );
    1321           0 :                     if( xDocument.is() && xExporter.is() && mpFB )
    1322             :                     {
    1323             :                         Reference< XOutputStream > xOutStream = mpFB->openFragmentStream( OUStringBuffer()
    1324           0 :                                                                                           .appendAscii( GetComponentDir() )
    1325           0 :                                                                                           .appendAscii( "/embeddings/spreadsheet" )
    1326           0 :                                                                                           .append( (sal_Int32) mnSpreadsheetCounter )
    1327           0 :                                                                                           .appendAscii( ".xlsx" )
    1328             :                                                                                           .makeStringAndClear(),
    1329           0 :                                                                                           S("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") );
    1330             :                         // export the embedded document
    1331           0 :                         Sequence< PropertyValue > rMedia(1);
    1332             : 
    1333           0 :                         rMedia[0].Name = MediaDescriptor::PROP_STREAMFOROUTPUT();
    1334           0 :                         rMedia[0].Value <<= xOutStream;
    1335             : 
    1336           0 :                         Reference< XFilter > xFilter( xExporter, UNO_QUERY );
    1337             : 
    1338           0 :                         if( xFilter.is() )
    1339             :                         {
    1340           0 :                             xExporter->setSourceDocument( xDocument );
    1341           0 :                             xFilter->filter( rMedia );
    1342             :                         }
    1343             : 
    1344           0 :                         xOutStream->closeOutput();
    1345             : 
    1346             :                         OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
    1347             :                                                              US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package" ),
    1348             :                                                              OUStringBuffer()
    1349           0 :                                                              .appendAscii( GetRelationCompPrefix() )
    1350           0 :                                                              .appendAscii( "embeddings/spreadsheet" )
    1351           0 :                                                              .append( (sal_Int32) mnSpreadsheetCounter ++ )
    1352           0 :                                                              .appendAscii( ".xlsx" )
    1353           0 :                                                              .makeStringAndClear() );
    1354             : 
    1355           0 :                         mpFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
    1356             : 
    1357           0 :                         mpFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
    1358             : 
    1359             :                         mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
    1360             :                                                XML_id,     I32S( GetNewShapeID( xShape ) ),
    1361           0 :                                                XML_name,   IDS(Object),
    1362           0 :                                                FSEND );
    1363             : 
    1364             :                         mpFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
    1365           0 :                                                FSEND );
    1366             : 
    1367           0 :                         if( GetDocumentType() == DOCUMENT_PPTX )
    1368             :                             mpFS->singleElementNS( mnXmlNamespace, XML_nvPr,
    1369           0 :                                                    FSEND );
    1370           0 :                         mpFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
    1371             : 
    1372           0 :                         WriteShapeTransformation( xShape, mnXmlNamespace );
    1373             : 
    1374           0 :                         mpFS->startElementNS( XML_a, XML_graphic, FSEND );
    1375             :                         mpFS->startElementNS( XML_a, XML_graphicData,
    1376             :                                               XML_uri, "http://schemas.openxmlformats.org/presentationml/2006/ole",
    1377           0 :                                               FSEND );
    1378             :                         mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
    1379             :                                               XML_name, "Spreadsheet",
    1380             :                                               FSNS(XML_r, XML_id), USS( sRelId ),
    1381           0 :                                               FSEND );
    1382             : 
    1383           0 :                         mpFS->singleElementNS( mnXmlNamespace, XML_embed, FSEND );
    1384             : 
    1385             :                         // pic element
    1386           0 :                         SdrObject* pSdrOLE2( GetSdrObjectFromXShape( xShape ) );
    1387           0 :                         if ( pSdrOLE2 && pSdrOLE2->ISA( SdrOle2Obj ) )
    1388             :                         {
    1389           0 :                             Graphic* pGraphic = ((SdrOle2Obj*)pSdrOLE2)->GetGraphic();
    1390           0 :                             if ( pGraphic )
    1391           0 :                                 WriteGraphicObjectShapePart( xShape, pGraphic );
    1392             :                         }
    1393             : 
    1394           0 :                         mpFS->endElementNS( mnXmlNamespace, XML_oleObj );
    1395             : 
    1396           0 :                         mpFS->endElementNS( XML_a, XML_graphicData );
    1397           0 :                         mpFS->endElementNS( XML_a, XML_graphic );
    1398             : 
    1399           0 :                         mpFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
    1400           0 :                     }
    1401           0 :                 }
    1402           0 :             }
    1403             :         }
    1404             :     }
    1405           0 :     return *this;
    1406             : }
    1407             : 
    1408           0 : ShapeExport& ShapeExport::WriteUnknownShape( Reference< XShape > )
    1409             : {
    1410             :     // Override this method to do something useful.
    1411           0 :     return *this;
    1412             : }
    1413             : 
    1414           0 : size_t ShapeExport::ShapeHash::operator()( const Reference < XShape > rXShape ) const
    1415             : {
    1416           0 :     return rXShape->getShapeType().hashCode();
    1417             : }
    1418             : 
    1419           0 : sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape > rXShape )
    1420             : {
    1421           0 :     return GetNewShapeID( rXShape, GetFB() );
    1422             : }
    1423             : 
    1424           0 : sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape > rXShape, XmlFilterBase* pFB )
    1425             : {
    1426           0 :     if( !rXShape.is() )
    1427           0 :         return -1;
    1428             : 
    1429           0 :     sal_Int32 nID = pFB->GetUniqueId();
    1430             : 
    1431           0 :     (*mpShapeMap)[ rXShape ] = nID;
    1432             : 
    1433           0 :     return nID;
    1434             : }
    1435             : 
    1436           0 : sal_Int32 ShapeExport::GetShapeID( const Reference< XShape > rXShape )
    1437             : {
    1438           0 :     return GetShapeID( rXShape, mpShapeMap );
    1439             : }
    1440             : 
    1441           0 : sal_Int32 ShapeExport::GetShapeID( const Reference< XShape > rXShape, ShapeHashMap* pShapeMap )
    1442             : {
    1443           0 :     if( !rXShape.is() )
    1444           0 :         return -1;
    1445             : 
    1446           0 :     ShapeHashMap::const_iterator aIter = pShapeMap->find( rXShape );
    1447             : 
    1448           0 :     if( aIter == pShapeMap->end() )
    1449           0 :         return -1;
    1450             : 
    1451           0 :     return aIter->second;
    1452             : }
    1453             : 
    1454         174 : } }
    1455             : 
    1456             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10