File indexing completed on 2025-01-19 10:49:23

0001 /*
0002  * This file is part of Office 2007 Filters for Calligra
0003  *
0004  * SPDX-FileCopyrightText: 2010 Nokia Corporation and /or its subsidiary(-ies).
0005  *
0006  * Contact: Suresh Chande suresh.chande@nokia.com
0007  *
0008  * SPDX-License-Identifier: LGPL-2.1-only
0009  *
0010  */
0011 
0012 /*! @file MsooXmlVmlReaderMethods.h
0013     @brief Collects MS VML parser code.
0014 
0015     Included by MsooXmlCommonReader.
0016     MS VML is not a part of the approved OOXML,
0017     it is described in ECMA-376 Part 4: "Transitional Migration Features".
0018     Required for interoperability in any version of MSOOXML.
0019     VML elements are referenced in ECMA-376 Part 1.
0020 
0021     All page numbers of the ECMA-376 documents refer to the 2nd edition.
0022 */
0023 
0024 protected:
0025 
0026     enum FrameStartElement {FrameStart, EllipseStart, RectStart, LineStart, CustomStart, GroupStart};
0027 
0028     // v namespace:
0029     KoFilter::ConversionStatus genericReader(FrameStartElement startType);
0030     KoFilter::ConversionStatus read_oval();
0031     KoFilter::ConversionStatus read_line();
0032     KoFilter::ConversionStatus read_roundrect();
0033     KoFilter::ConversionStatus read_rect();
0034     KoFilter::ConversionStatus read_fill();
0035     KoFilter::ConversionStatus read_VML_background();
0036     KoFilter::ConversionStatus read_shapetype();
0037     KoFilter::ConversionStatus read_formulas();
0038     KoFilter::ConversionStatus read_path();
0039     KoFilter::ConversionStatus read_f();
0040     KoFilter::ConversionStatus read_shape();
0041     KoFilter::ConversionStatus read_imagedata();
0042     KoFilter::ConversionStatus read_textbox();
0043     KoFilter::ConversionStatus read_group();
0044     KoFilter::ConversionStatus read_stroke();
0045     KoFilter::ConversionStatus read_shadow();
0046 
0047     void handlePathValues(const QXmlStreamAttributes& attrs);
0048     void handleStrokeAndFill(const QXmlStreamAttributes& attrs);
0049     void takeDefaultValues();
0050 
0051     QString rgbColor(QString color);
0052 
0053     // w:10 namespace:
0054     KoFilter::ConversionStatus read_wrap();
0055 
0056     void createFrameStart(FrameStartElement startType = FrameStart);
0057 
0058     // utils:
0059     KoFilter::ConversionStatus parseCSS(const QString& style);
0060 
0061     //writer where style:background-image is stored for style:page-layout-properties
0062     KoXmlWriter* m_pDocBkgImageWriter;
0063 
0064 public:
0065 
0066     struct VMLShapeProperties {
0067         QString currentEl;
0068 
0069         QMap<QByteArray, QString> vmlStyle;
0070 
0071         QString strokeColor; // stroke color
0072         QString strokeWidth; // stroke width
0073         QString lineCapStyle;
0074         QString joinStyle;
0075         QString strokeStyleName;
0076         QString fillType;
0077         QString gradientStyle;
0078         QString shapeColor; //!< set in read_shape()
0079         QString shapeSecondaryColor; // used eg. for some gradients
0080 
0081         qreal opacity;
0082 
0083         bool wrapRead;
0084         QString currentShapeId; //!< set in read_shape()
0085         QString imagedataPath; //!< set in read_shape()
0086         QString shapeAltText; //!< set in read_shape()
0087         QString shapeTitle; //!< set in read_shape()
0088 
0089         bool stroked, filled, shadowed;
0090 
0091         QString shadowColor;
0092         QString shadowXOffset, shadowYOffset;
0093         qreal shadowOpacity;
0094 
0095         QString anchorType;
0096 
0097         int formulaIndex;
0098         QString shapeTypeString;
0099         QString extraShapeFormulas;
0100         QString normalFormulas;
0101         QString modifiers;
0102         QString viewBox;
0103         QString shapePath;
0104         int extraFormulaIndex;
0105 
0106         QString internalMarginLeft;
0107         QString internalMarginRight;
0108         QString internalMarginTop;
0109         QString internalMarginBottom;
0110 
0111         QString marginLeft;
0112         QString marginTop;
0113         QString marginRight;
0114         QString marginBottom;
0115 
0116         bool fitTextToShape, fitShapeToText;
0117 
0118         // Parameters for group shape situation
0119         bool insideGroup;
0120         int groupWidth, groupHeight; // Relative group extends
0121         int groupX, groupY; // Relative group origin
0122         qreal groupXOffset, groupYOffset; // Offset caused by the group parent
0123         qreal real_groupWidth, real_groupHeight;
0124     };
0125 
0126     // Elements defined by v:shapeType
0127     QMap<QString, VMLShapeProperties> m_definedShapeTypes;
0128 
0129 protected:
0130 
0131     VMLShapeProperties m_currentVMLProperties;
0132 
0133     // Using stack to make sure correct properties are handled in a case when
0134     // there are group shapes
0135     QStack<VMLShapeProperties> m_VMLShapeStack;
0136 
0137     bool m_outputFrames; // Whether read_shape should output something to shape