[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bcalligra=5D_filters/kpresenter/powerpoint=3A_PPT=3A?=
From:       Matus Uzak <matus.uzak () ixonos ! com>
Date:       2011-02-03 19:10:19
Message-ID: 20110203191019.0D967A609B () git ! kde ! org
[Download RAW message or body]

Git commit c52c55a1b1f7790a1d6caa8959f1be6aafe6a3d7 by Matus Uzak.
Committed on 03/02/11 at 20:05.
Pushed by uzak into branch 'master'.

PPT: Removed the deprecated defineTextProperties function.

* Now we have to reuse the super great defineTextProperties function to create
  the text style for the bullet/number of a list.
* Rewrote some code in order to remove to deprecated function.

M  +28   -188  filters/kpresenter/powerpoint/PptToOdp.cpp     
M  +8    -12   filters/kpresenter/powerpoint/PptToOdp.h     
M  +11   -17   filters/kpresenter/powerpoint/pptstyle.cpp     
M  +13   -0    filters/kpresenter/powerpoint/pptstyle.h     

http://commits.kde.org/calligra/c52c55a1b1f7790a1d6caa8959f1be6aafe6a3d7

diff --git a/filters/kpresenter/powerpoint/PptToOdp.cpp b/filters/kpresenter/powerpoint/PptToOdp.cpp
index 10d18c3..161dcde 100644
--- a/filters/kpresenter/powerpoint/PptToOdp.cpp
+++ b/filters/kpresenter/powerpoint/PptToOdp.cpp
@@ -378,8 +378,10 @@ KoGenStyle PptToOdp::DrawClient::createGraphicStyle(
     quint32 textType = ppttoodp->getTextType(tb, cd);
     bool isPlaceholder = cd && cd->placeholderAtom;
     if (isPlaceholder) { // type is presentation
-        bool canBeParentStyle = textType != 99 && out.stylesxml
-                                && dc_data->masterSlide;
+        bool canBeParentStyle = false;
+        if ( (textType != 99) && out.stylesxml && dc_data->masterSlide) {
+            canBeParentStyle = true;
+        }
         bool isAutomatic = !canBeParentStyle;
 
         // if this object has a placeholder type, it defines a presentation style,
@@ -396,8 +398,8 @@ KoGenStyle PptToOdp::DrawClient::createGraphicStyle(
         QString parent;
         // for now we only set parent styles on presentation styled elements
         if (dc_data->masterSlide) {
-            parent = getMasterStyle(
-                    ppttoodp->masterPresentationStyles[dc_data->masterSlide], textType);
+            parent = getMasterStyle(ppttoodp->masterPresentationStyles[dc_data->masterSlide],
+                                    textType);
         }
         if (!parent.isEmpty()) {
             style.setParentName(parent);
@@ -434,17 +436,20 @@ void PptToOdp::DrawClient::addTextStyles(
     if (clientTextbox) {
         tb = clientTextbox->anon.get<PptOfficeArtClientTextBox>();
     }
-    quint32 textType = ppttoodp->getTextType(tb, cd);
-    const TextMasterStyleAtom* listStyle = 0;
     if (out.stylesxml) {
-        listStyle = getTextMasterStyleAtom(dc_data->masterSlide, textType);
-    }
-    if (listStyle && listStyle->lstLvl1) {
+        const TextContainer* tc = ppttoodp->getTextContainer(tb, cd);
+
+        //TODO: provide the corresponding TextRulerAtom
         PptTextPFRun pf(ppttoodp->p->documentContainer,
+                        dc_data->slideTexts,
                         dc_data->masterSlide,
-                        textType);
+                        cd, tc);
         ppttoodp->defineParagraphProperties(style, pf, 0);
-        ppttoodp->defineTextProperties(style, &listStyle->lstLvl1->cf, 0, 0, 0);
+
+        QList<const MasterOrSlideContainer*> mh;
+        mh.append(dc_data->masterSlide);
+        PptTextCFRun cf(ppttoodp->p->documentContainer, mh, &tc, 0);
+        ppttoodp->defineTextProperties(style, &cf, 0, 0, 0);
     }
     bool isPlaceholder = cd && cd->placeholderAtom;
     if (isPlaceholder) {
@@ -470,8 +475,11 @@ void PptToOdp::DrawClient::addTextStyles(
     } else {
         out.xml.addAttribute("draw:style-name", styleName);
     }
-    bool canBeParentStyle = isPlaceholder && textType != 99 && out.stylesxml
-                                && dc_data->masterSlide;
+    quint32 textType = ppttoodp->getTextType(tb, cd);
+    bool canBeParentStyle = false;
+    if (isPlaceholder && (textType != 99) && out.stylesxml && dc_data->masterSlide) {
+        canBeParentStyle = true;
+    }
     if (canBeParentStyle) {
         ppttoodp->masterPresentationStyles[dc_data->masterSlide][textType] = styleName;
     }
@@ -818,14 +826,11 @@ void PptToOdp::defineDefaultChartStyle(KoGenStyles& styles)
 }
 
 void PptToOdp::defineDefaultTextProperties(KoGenStyle& style) {
-    const TextCFException* cf = 0;
+    const PptTextCFRun cf(p->documentContainer);
     const TextCFException9* cf9 = 0;
     const TextCFException10* cf10 = 0;
     const TextSIException* si = 0;
     if (p->documentContainer) {
-        if (p->documentContainer->documentTextInfo.textCFDefaultsAtom) {
-            cf = &p->documentContainer->documentTextInfo.textCFDefaultsAtom->cf;
-        }
         const PP9DocBinaryTagExtension* pp9 = getPP<PP9DocBinaryTagExtension>(
                 p->documentContainer);
         const PP10DocBinaryTagExtension* pp10 = getPP<PP10DocBinaryTagExtension>(
@@ -838,7 +843,7 @@ void PptToOdp::defineDefaultTextProperties(KoGenStyle& style) {
         }
         si = &p->documentContainer->documentTextInfo.textSIDefaultsAtom.textSIException;
     }
-    defineTextProperties(style, cf, cf9, cf10, si);
+    defineTextProperties(style, &cf, cf9, cf10, si);
 }
 
 void PptToOdp::defineDefaultParagraphProperties(KoGenStyle& style) {
@@ -850,6 +855,7 @@ void PptToOdp::defineDefaultParagraphProperties(KoGenStyle& style) {
             pf9 = &pp9->textDefaultsAtom->pf9;
         }
     }
+    //TODO: provide the default TextRulerAtom
     PptTextPFRun pf(p->documentContainer);
     defineParagraphProperties(style, pf, 0);
 }
@@ -978,174 +984,6 @@ void PptToOdp::defineTextProperties(KoGenStyle& style,
     // style:use-window-font-color
 }
 
-//NOTE: required by defineDefaultTextProperties and addTextStyles
-void PptToOdp::defineTextProperties(KoGenStyle& style,
-                                    const MSO::TextCFException* cf,
-                                    const TextCFException9* /*cf9*/,
-                                    const TextCFException10* /*cf10*/,
-                                    const TextSIException* si,
-                                    const TextContainer* tc)
-{
-    const KoGenStyle::PropertyType text = KoGenStyle::TextType;
-    /* We try to get information for all the possible attributes in
-       style:text-properties for clarity we handle them in alphabetical order */
-    // fo:background-color
-    // fo:color
-    if (cf && cf->masks.color && cf->color) {
-        QColor color = toQColor(*cf->color);
-        if (color.isValid()) {
-            style.addProperty("fo:color", color.name(), text);
-        }
-    }
-
-    // NOTE: TOTALLY WRONG APPROACH !!!!!!!  You have to check the corresponding
-    // master shape if you don't have a color!!!  And check if there's a master
-    // slide for it!!!  Check the implementation of defineTextProperties above.
-    //
-    // Use the color defined by the corresponding color scheme.  Let's create a
-    // temporary OfficeArtCOLORREF to reuse the toQColor function.  The red
-    // value will be treated as an index into the current color scheme table.
-    else {
-        OfficeArtCOLORREF tmp;
-        quint32 tt = Text::Other;
-        QColor color;
-
-        tmp.fSchemeIndex = true;
-        if (tc) {
-            tt = tc->textHeaderAtom.textType;
-        }
-	//TODO: check TextTypeEnum (2.13.33) for all text types to be handled
-	//or provide TextCFException.
-        switch (tt) {
-        case Text::Title: 
-        case Text::CenterTitle:
-            tmp.red = Color::TitleText;
-            break;
-        default:
-            tmp.red = Color::Text;
-            break;
-        }
-
-	const MSO::MasterOrSlideContainer* m = m_currentMaster;
-	const MSO::MainMasterContainer* mm = NULL;
-	const MSO::SlideContainer* tm = NULL;
-
-        if (m) {
-            if (m->anon.is<MainMasterContainer>()) {
-                mm = m->anon.get<MainMasterContainer>();
-                color = toQColor(tmp, mm, m_currentSlide);
-            } else if (m->anon.is<SlideContainer>()) {
-                tm = m->anon.get<SlideContainer>();
-                color = toQColor(tmp, tm, m_currentSlide);
-            }
-        }
-        //TODO: handle the case of a notes master slide/notes slide pair
-
-        style.addProperty("fo:color", color.name(), text);
-    }
-    // fo:country
-    // fo:font-family
-    if (cf && cf->masks.typeface) {
-        const FontEntityAtom* font = getFont(cf->fontRef);
-        if (font) {
-            const QString name= QString::fromUtf16(font->lfFaceName.data(),
-                                                   font->lfFaceName.size());
-            style.addProperty("fo:font-family", name, text);
-        }
-    }
-    // fo:font-size
-    if (cf && cf->masks.size) {
-        style.addProperty("fo:font-size", pt(cf->fontSize), text);
-    }
-    // fo:font-style: "italic", "normal" or "oblique
-    if (cf && cf->masks.italic && cf->fontStyle) {
-        style.addProperty("fo:font-style",
-                          cf->fontStyle->italic ?"italic" :"normal", text);
-    }
-    // fo:font-variant: "normal" or "small-caps"
-    // fo:font-weight: "100", "200", "300", "400", "500", "600", "700", "800", "900", "bold" or "normal"
-    if (cf && cf->masks.bold && cf->fontStyle) {
-        style.addProperty("fo:font-weight",
-                          cf->fontStyle->bold ?"bold" :"normal", text);
-    }
-    // fo:hyphenate
-    // fo:hyphenation-push-char
-    // fo:hyphenation-remain-char-count
-    // fo:language
-    if (si && si->lang) {
-        // TODO: get mapping from lid to language code
-    }
-    // fo:letter-spacing
-    // fo:text-shadow
-    if (cf && cf->masks.shadow) {
-        style.addProperty("fo:text-shadow",
-                          cf->fontStyle->shadow ?"1pt 1pt" :"none", text);
-    }
-    // fo:text-transform: "capitalize", "lowercase", "none" or "uppercase"
-    // style:country-asian
-    // style:country-complex
-    // style:font-charset
-    // style:font-family-asian
-    // style:font-family-complex
-    // style:font-family-generic
-    // style:font-family-generic-asian
-    // style:font-family-generic-complex
-    // style:font-name
-    // style:font-name-asian
-    // style:font-name-complex
-    // style:font-pitch
-    // style:font-pitch-asian
-    // style:font-pitch-complex
-    // style:font-relief: "embossed", "engraved" or "none"
-    if (cf && cf->masks.emboss) {
-        style.addProperty("style:font-relief",
-                          cf->fontStyle->emboss ?"embossed" :"none", text);
-    }
-    // style:font-size-asian
-    // style:font-size-complex
-    // style:font-size-rel
-    // style:font-size-rel-asian
-    // style:font-size-rel-complex
-    // style:font-style-asian
-    // style:font-style-complex
-    // style:font-style-name
-    // style:font-style-name-asian
-    // style:font-style-name-complex
-    // style:font-weight-asian
-    // style:font-weight-complex
-    // style:language-asian
-    // style:language-complex
-    // style:letter-kerning
-    // style:script-type
-    // style:text-blinking
-    // style:text-combine
-    // style:text-combine-end-char
-    // style:text-combine-start-char
-    // style:text-emphasize
-    // style:text-line-through-color
-    // style:text-line-through-mode
-    // style:text-line-through-style
-    // style:text-line-through-text
-    // style:text-line-through-text-style
-    // style:text-line-through-type
-    // style:text-line-through-width
-    // style:text-outline
-    // style:text-position
-    // style:text-rotation-angle
-    // style:text-rotation-scale
-    // style:text-scale
-    // style:text-underline-color
-    // style:text-underline-mode
-    // style:text-underline-style
-    // style:text-underline-type: "double", "none" or "single"
-    if (cf && cf->masks.underline) {
-        style.addProperty("style:text-underline-type",
-                          cf->fontStyle->underline ?"single" :"none", text);
-    }
-    // style:text-underline-width
-    // style:use-window-font-color
-}
-
 void PptToOdp::defineParagraphProperties(KoGenStyle& style, const PptTextPFRun& pf,
                                          quint16 fs)
 {
@@ -1521,8 +1359,10 @@ void PptToOdp::defineListStyle(KoGenStyle& style, quint8 depth,
 
     if (!imageBullet) {
         KoGenStyle ls(KoGenStyle::TextStyle);
-        defineTextProperties(ls, p.cf, p.cf9, p.cf10, p.si);
-        defineTextProperties(ls, i.cf, i.cf9, i.cf10, i.si);
+
+        //FIXME: PptTextCFRun required!!!!!
+//         defineTextProperties(ls, p.cf, p.cf9, p.cf10, p.si);
+//         defineTextProperties(ls, i.cf, i.cf9, i.cf10, i.si);
 
         // override some properties with information from the paragraph
         if (hasIndent) {
diff --git a/filters/kpresenter/powerpoint/PptToOdp.h b/filters/kpresenter/powerpoint/PptToOdp.h
index 68c740b..7fd9fdc 100644
--- a/filters/kpresenter/powerpoint/PptToOdp.h
+++ b/filters/kpresenter/powerpoint/PptToOdp.h
@@ -267,23 +267,19 @@ private:
     void defineDefaultParagraphProperties(KoGenStyle& style);
     void defineDefaultGraphicProperties(KoGenStyle& style, KoGenStyles& styles);
 
-    /* Extract data from TextCFException into the style */
-
-    void defineTextProperties(KoGenStyle& style,
-                              const PptTextCFRun* cf,
-                              const MSO::TextCFException9* cf9,
-                              const MSO::TextCFException10* cf10,
-                              const MSO::TextSIException* si);
-
     /**
-     * Deprecated
+     * Extract data from TextCFException into the style
+     * @param KoGenStyle of type TextStyle
+     * @param PptTextCFRun address
+     * @param TextCFException9 address
+     * @param TextCFException10 address
+     * @param TextSIException address
      */
     void defineTextProperties(KoGenStyle& style,
-                              const MSO::TextCFException* cf,
+                              const PptTextCFRun* cf,
                               const MSO::TextCFException9* cf9,
                               const MSO::TextCFException10* cf10,
-                              const MSO::TextSIException* si,
-                              const MSO::TextContainer* tc = NULL);
+                              const MSO::TextSIException* si);
 
     /**
      * Extract data from TextPFException into the style
diff --git a/filters/kpresenter/powerpoint/pptstyle.cpp b/filters/kpresenter/powerpoint/pptstyle.cpp
index 65872cd..0bf0e09 100644
--- a/filters/kpresenter/powerpoint/pptstyle.cpp
+++ b/filters/kpresenter/powerpoint/pptstyle.cpp
@@ -427,22 +427,6 @@ getTextCFException(const MSO::TextContainer* tc, const int start)
     return &cfs[i].cf;
 }
 
-PptTextPFRun::PptTextPFRun(const MSO::DocumentContainer* d,
-             const MSO::MasterOrSlideContainer* m,
-             quint32 textType)
-{
-    m_level = 0;
-    *pfs = 0;
-    addStyle(pfs, getLevelPF(m, textType, 0));
-    addStyle(pfs, getDefaultLevelPF(d, 0));
-    addStyle(pfs, getDefaultPF(d));
-
-    *pf9s = 0;
-    addStyle(pf9s, getLevelPF9(m, textType, 0));
-    addStyle(pf9s, getDefaultLevelPF9(d, textType, 0));
-    addStyle(pf9s, getDefaultPF9(d));
-}
-
 PptTextPFRun::PptTextPFRun(const DocumentContainer* d,
                            const SlideListWithTextSubContainerOrAtom* texts,
                            const MasterOrSlideContainer* m,
@@ -530,6 +514,16 @@ PptTextCFRun::PptTextCFRun(const MSO::DocumentContainer* d,
     cfrun_rm = false;
 }
 
+PptTextCFRun::PptTextCFRun(const MSO::DocumentContainer* d)
+{
+    //check DocumentContainer/DocumentTextInfoContainer/textCFDefaultsAtom
+    cfs.append(getDefaultCF(d));
+    cfrun_rm = false;
+
+    //It MUST be less than or equal to 0x0005 (not required here)
+    m_level = 99;
+}
+
 int PptTextCFRun::addCurrentCFRun(const MSO::TextContainer& tc, quint32 start)
 {
     int n = 0;
@@ -607,7 +601,7 @@ TYPE PptTextPFRun::NAME() const \
     const MSO::TextPFException* const * p = pfs; \
     while (*p) { \
         if ((*p)->masks.TEST) { \
- 	    if (VALID()) { \
+            if (VALID()) { \
                 return PRE (*p)->NAME; \
             } \
         } \
diff --git a/filters/kpresenter/powerpoint/pptstyle.h b/filters/kpresenter/powerpoint/pptstyle.h
index 40b5531..bffc4de 100644
--- a/filters/kpresenter/powerpoint/pptstyle.h
+++ b/filters/kpresenter/powerpoint/pptstyle.h
@@ -96,12 +96,25 @@ class PptTextCFRun {
     quint16 m_level;
     bool cfrun_rm;
 public:
+    /**
+     * All TextCFExceptions are required.
+     * @param DocumentContainer
+     * @param MasterOrSlideContainer hierarchy
+     * @param TextContainer
+     * @param level specifies the indentation level of the paragraph
+     */
     PptTextCFRun(const MSO::DocumentContainer* d,
                  QList<const MSO::MasterOrSlideContainer*> &mh,
                  const MSO::TextContainer& tc,
                  quint16 level);
 
     /**
+     * Only default TextCFExceptions are required.
+     * @param DocumentContainer
+     */
+    PptTextCFRun(const MSO::DocumentContainer* d);
+
+    /**
      * Add the TextCFException structure present in the current TextContainer,
      * which specifies character-level style and formatting, font information,
      * coloring and positioninghe for the given run of text.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic