1 /* 2 * This file is part of Office 2007 Filters for Calligra 3 * 4 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 5 * Contact: Suresh Chande suresh.chande@nokia.com 6 * 7 * Copyright (C) 2011-2012 Matus Uzak (matus.uzak@gmail.com). 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public License 11 * version 2.1 as published by the Free Software Foundation. 12 * 13 * This library is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 21 * 02110-1301 USA 22 * 23 */ 24 25 // This is not a normal header, *don't* add include guards to it. 26 // This will cause the compiler to get wrong offsets and to corrupt 27 // the stack. 28 29 protected: 30 31 #include "MsooXmlDrawingMLShared.h" 32 33 //! When dealing with colors there's no way to know what type of 34 //! attribute we are setting. While MSOOXML doesn't need to know the 35 //! context in which a color is used, ODF does need to know this. 36 enum ColorType { 37 BackgroundColor, 38 OutlineColor, 39 TextColor, 40 GradientColor 41 }; 42 43 enum blipFillCaller { 44 blipFill_lockedCanvas = 'a', 45 blipFill_spPr = 'a', 46 blipFill_pic = 'p', //dml in pptx; for dml in docx use 'pic' 47 blipFill_rPr = 'p', //dml 48 blipFill_bgPr = 'a', // pptx 49 blipFill_grpSpPr = 'a' 50 }; 51 52 enum cNvPrCaller { 53 cNvPr_nvSpPr, 54 cNvPr_nvPicPr, 55 cNvPr_nvCxnSpPr 56 }; 57 58 enum txBodyCaller { 59 DrawingML_txBody_tc, 60 DrawingML_txBody_txSp, 61 DrawingML_txBody_sp 62 }; 63 64 enum spacingType { 65 spacingMarginTop, 66 spacingLines, 67 spacingMarginBottom 68 }; 69 70 struct GroupProp { 71 qint64 svgXOld; 72 qint64 svgYOld; 73 qreal svgWidthOld; 74 qreal svgHeightOld; 75 qreal svgXChOld; 76 qreal svgYChOld; 77 qreal svgWidthChOld; 78 qreal svgHeightChOld; 79 }; 80 81 void initDrawingML(); 82 83 /** 84 * @return true in case a custom or supported predefined shape is 85 * being processed and false in case of a text-box and rectangle. 86 */ 87 bool isCustomShape(); 88 89 /** 90 * @return true in case an unsupported shape is being processed. 91 */ 92 bool unsupportedPredefinedShape(); 93 94 /** 95 * TODO: 96 */ 97 void preReadSp(); 98 99 /** 100 * Write the parent el. in {draw:line, draw:custom-shape, draw:frame} 101 * to the body writer and create a graphic style for a shape. 102 */ 103 void generateFrameSp(); 104 105 /** 106 * Write the draw:enhanced-geometry element to the body writer in case 107 * of a draw:custom-shape. 108 */ 109 void writeEnhancedGeometry(); 110 111 // ---------------------------------------- 112 // MSOOXML_CURRENT_NS "dgm" 113 // ---------------------------------------- 114 KoFilter::ConversionStatus read_relIds(); 115 116 // ---------------------------------------- 117 // MSOOXML_CURRENT_NS "c" 118 // ---------------------------------------- 119 KoFilter::ConversionStatus read_chart(); 120 121 // ---------------------------------------- 122 // MSOOXML_CURRENT_NS "lc" 123 // ---------------------------------------- 124 KoFilter::ConversionStatus read_lockedCanvas(); 125 126 // ---------------------------------------- 127 // MSOOXML_CURRENT_NS == DRAWINGML_PIC_NS 128 // ---------------------------------------- 129 // The following elements can have a namespace in {a,pic,p,xdr}. 130 KoFilter::ConversionStatus read_cNvPicPr(); //done 131 KoFilter::ConversionStatus read_cNvPr(cNvPrCaller caller); //done 132 KoFilter::ConversionStatus read_nvPicPr(); //done 133 KoFilter::ConversionStatus read_pic(); //done 134 KoFilter::ConversionStatus read_nvSpPr(); //done 135 KoFilter::ConversionStatus read_grpSp(); //done 136 KoFilter::ConversionStatus read_grpSpPr(); //done 137 KoFilter::ConversionStatus read_nvCxnSpPr(); //done 138 KoFilter::ConversionStatus read_cNvSpPr(); //done 139 KoFilter::ConversionStatus read_cxnSp(); //done 140 KoFilter::ConversionStatus read_sp(); //done 141 KoFilter::ConversionStatus read_spPr(); //done 142 KoFilter::ConversionStatus read_style(); //done 143 144 // ---------------------------------------- 145 // MSOOXML_CURRENT_NS "a" 146 // ---------------------------------------- 147 KoFilter::ConversionStatus read_lnRef(); 148 KoFilter::ConversionStatus read_masterClrMapping(); 149 KoFilter::ConversionStatus read_overrideClrMapping(); 150 KoFilter::ConversionStatus read_DrawingML_p(); 151 KoFilter::ConversionStatus read_DrawingML_r(); 152 KoFilter::ConversionStatus read_DrawingML_br(); 153 KoFilter::ConversionStatus read_endParaRPr(); 154 KoFilter::ConversionStatus read_DrawingML_rPr(); 155 KoFilter::ConversionStatus read_DrawingML_pPr(); 156 KoFilter::ConversionStatus read_hlinkClick(); 157 KoFilter::ConversionStatus read_custGeom(); 158 KoFilter::ConversionStatus read_xfrm(); 159 KoFilter::ConversionStatus read_off(); 160 KoFilter::ConversionStatus read_chOff(); 161 KoFilter::ConversionStatus read_ext(); 162 KoFilter::ConversionStatus read_chExt(); 163 KoFilter::ConversionStatus read_blip(); 164 KoFilter::ConversionStatus read_stretch(); 165 KoFilter::ConversionStatus read_biLevel(); 166 KoFilter::ConversionStatus read_grayscl(); 167 KoFilter::ConversionStatus read_lum(); 168 KoFilter::ConversionStatus read_duotone(); 169 KoFilter::ConversionStatus read_tile(); 170 KoFilter::ConversionStatus read_srcRect(); 171 KoFilter::ConversionStatus read_fillRect(); 172 KoFilter::ConversionStatus read_graphic(); 173 KoFilter::ConversionStatus read_graphicData(); 174 KoFilter::ConversionStatus read_blipFill(blipFillCaller caller); 175 KoFilter::ConversionStatus read_txSp(); 176 177 //! Convert attributes of Text Run Properties to ODF equivalents. 178 void handleRprAttributes(const QXmlStreamAttributes& attrs); 179 180 // ---------------------------------------- 181 // MSOOXML_CURRENT_NS == DRAWINGML_NS 182 // ---------------------------------------- 183 // The following elements can have a namespace in {a,wp}. 184 KoFilter::ConversionStatus read_lstStyle(); 185 KoFilter::ConversionStatus read_latin(); 186 KoFilter::ConversionStatus read_DrawingML_highlight(); 187 KoFilter::ConversionStatus read_gradFill(); 188 KoFilter::ConversionStatus read_gradFillRpr(); 189 KoFilter::ConversionStatus read_lin(); 190 KoFilter::ConversionStatus read_gsLst(); 191 KoFilter::ConversionStatus read_gs(); 192 KoFilter::ConversionStatus read_noFill(); 193 KoFilter::ConversionStatus read_prstGeom(); 194 KoFilter::ConversionStatus read_avLst(); 195 KoFilter::ConversionStatus read_gd(); 196 KoFilter::ConversionStatus read_effectLst(); 197 KoFilter::ConversionStatus read_outerShdw(); 198 KoFilter::ConversionStatus lvlHelper(const QString& level); 199 KoFilter::ConversionStatus read_lvl1pPr(); 200 KoFilter::ConversionStatus read_lvl2pPr(); 201 KoFilter::ConversionStatus read_lvl3pPr(); 202 KoFilter::ConversionStatus read_lvl4pPr(); 203 KoFilter::ConversionStatus read_lvl5pPr(); 204 KoFilter::ConversionStatus read_lvl6pPr(); 205 KoFilter::ConversionStatus read_lvl7pPr(); 206 KoFilter::ConversionStatus read_lvl8pPr(); 207 KoFilter::ConversionStatus read_lvl9pPr(); 208 KoFilter::ConversionStatus read_buBlip(); 209 KoFilter::ConversionStatus read_buChar(); 210 KoFilter::ConversionStatus read_buClr(); 211 KoFilter::ConversionStatus read_buClrTx(); 212 KoFilter::ConversionStatus read_buSzPct(); 213 KoFilter::ConversionStatus read_buSzPts(); 214 KoFilter::ConversionStatus read_buFont(); 215 KoFilter::ConversionStatus read_buNone(); 216 KoFilter::ConversionStatus read_buAutoNum(); 217 KoFilter::ConversionStatus read_fld(); 218 KoFilter::ConversionStatus read_spcBef(); 219 KoFilter::ConversionStatus read_spcAft(); 220 KoFilter::ConversionStatus read_lnSpc(); 221 KoFilter::ConversionStatus read_spcPts(); 222 KoFilter::ConversionStatus read_spcPct(); 223 KoFilter::ConversionStatus read_defRPr(); 224 KoFilter::ConversionStatus read_bodyPr(); 225 KoFilter::ConversionStatus read_normAutofit(); 226 KoFilter::ConversionStatus read_spAutoFit(); 227 228 //! Inherit default body properties 229 void inheritDefaultBodyProperties(); 230 231 void algnToODF(const char *odfEl, const QString& emuValue); 232 233 //! Sets the fo:margin-* attribute of graphic-properties for read_anchor(). 234 void distToODF(const char *odfEl, const QString& emuValue); 235 236 // ---------------------------------------- 237 // MSOOXML_CURRENT_NS == (DRAWINGML_NS || DRAWINGML_TXBODY_NS) 238 // ---------------------------------------- 239 240 KoFilter::ConversionStatus read_DrawingML_txBody(txBodyCaller caller); 241 242 // ---------------------------------------- 243 244 MSOOXML::Utils::autoFitStatus m_normAutofit; // Whether text should be fitted to fit the shape 245 246 bool m_isLockedCanvas; 247 248 KoGenStyle m_referredFont; 249 250 int m_gradPosition; 251 QString m_gradAngle; 252 bool m_xfrm_read; 253 bool m_insideTable; 254 qreal m_maxParaFontPt; // Largest font size used in the paragraph 255 qreal m_minParaFontPt; // minimum font size used in the paragraph 256 read_p_args m_read_DrawingML_p_args; 257 258 bool m_contentAvLstExists; // whether avLst exists 259 QMap<QString, QString> m_avModifiers; 260 261 QString m_customPath; 262 QString m_customEquations; 263 QString m_textareas; 264 265 QString m_contentType; // read in prstGeom 266 267 spacingType m_currentSpacingType; // determines how spcPct and spcPts should behave 268 269 QString m_shapeTextPosition; 270 QString m_shapeTextTopOff; 271 QString m_shapeTextBottomOff; 272 QString m_shapeTextLeftOff; 273 QString m_shapeTextRightOff; 274 275 bool m_listStylePropertiesAltered; 276 QString m_prevListStyleName; 277 278 int m_prevListLevel; //! set by drawingML_ppr 279 int m_currentListLevel; //! set by drawingML_ppr 280 281 // Map of level keys and xml:id values of text:list elements to continue 282 // automatic numbering. 283 QMap<quint16, QString> m_lvlXmlIdMap; 284 285 // true - continue numbered list, false - restart numbering 286 QMap<quint16, bool> m_continueListNumbering; 287 288 //! set by read_drawing() to indicate if we have encountered 289 //! drawing/anchor, used by read_pic() 290 bool m_drawing_anchor; 291 292 //! set by read_drawing() to indicate if we have encountered 293 //! drawing/inline, used by read_pic() 294 bool m_drawing_inline; 295 296 // Shape properties 297 qint64 m_svgX; //!< set by read_off() 298 qint64 m_svgY; //!< set by read_off() 299 int m_svgWidth; //! set by read_ext() 300 int m_svgHeight; //! set by read_ext() 301 int m_svgChX; //!< set by read_chOff() 302 int m_svgChY; //!< set by read_chOff() 303 int m_svgChWidth; //! set by read_chExt() 304 int m_svgChHeight; //! set by read_chExt() 305 306 bool m_inGrpSpPr; //Whether we are in group shape, affects transformations 307 bool m_flipH; //! set by read_xfrm() 308 bool m_flipV; //! set by read_xfrm() 309 310 int m_rot; //! set by read_xfrm() 311 312 QVector<GroupProp> m_svgProp; //! value of the parent 313 314 QString m_xlinkHref; //!< set by read_blip() 315 bool m_ignoreLinkHref; //!< to ignore picture with a style which has picture fill 316 QString m_cNvPrId; //!< set by read_cNvPr() 317 QString m_cNvPrName; //!< set by read_cNvPr() 318 QString m_cNvPrDescr; //!< set by read_cNvPr() 319 320 bool m_hyperLink; 321 QString m_hyperLinkTarget; 322 323 QString m_recentDestName; // recent image 324 325