[Libreoffice-commits] .: 7 commits - sw/source xmloff/inc xmloff/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 14 06:05:57 PDT 2012


 sw/source/filter/xml/xmltble.cxx    |   11 +----
 xmloff/inc/xmloff/txtparae.hxx      |    3 +
 xmloff/source/draw/shapeexport2.cxx |   18 +++++++++
 xmloff/source/style/chrhghdl.cxx    |    2 +
 xmloff/source/style/xmlimppr.cxx    |    8 ++--
 xmloff/source/text/txtflde.cxx      |    1 
 xmloff/source/text/txtparae.cxx     |   69 +++++++++++++++++++++++++++---------
 xmloff/source/text/txtprmap.cxx     |    1 
 8 files changed, 84 insertions(+), 29 deletions(-)

New commits:
commit 9316effe51ca53cf16cf21e5a2d266349916edd1
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 14 13:52:46 2012 +0200

    SvXMLImportPropertyMapper::importXML: fix assertion to be less silly
    
    Change-Id: I009f0519e34900a1b1447de02d99f32dd0e07410

diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx
index 624b46d..16c5647 100644
--- a/xmloff/source/style/xmlimppr.cxx
+++ b/xmloff/source/style/xmlimppr.cxx
@@ -256,12 +256,12 @@ void SvXMLImportPropertyMapper::importXML(
 
             if( !bFound )
             {
+                SAL_INFO_IF((XML_NAMESPACE_NONE != nPrefix) &&
+                            !(XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) &&
+                            !bAlienImport, "xmloff.style",
+                            "unknown attribute: \"" << rAttrName << "\"");
                 if( (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) || (XML_NAMESPACE_NONE == nPrefix) || bAlienImport )
                 {
-                    OSL_ENSURE( XML_NAMESPACE_NONE == nPrefix ||
-                                (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) ||
-                                bAlienImport,
-                                "unknown attribute - might be a new feature?" );
                     if( !xAttrContainer.is() )
                     {
                         // add an unknown attribute container to the properties
commit 9a081484321b3f42bee3b43d18c4bd75b9603b01
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 14 13:42:47 2012 +0200

    fdo#49571: ODF import: ignore "text:enable-numbering" attribute
    
    It has been imported as an alien attribute since CWS impressodf12
    5b364c2e8baf9b1f6bbe611c0fd6895a88056afc, and could not be written
    to a document created from scratch anyway.
    
    Change-Id: I054fcf71d7ddc3ed19735b8aa898d1b1a12db5b9

diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 0853138..635d5e2 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -272,7 +272,6 @@ XMLPropertyMapEntry aXMLParaPropMap[] =
     MP_E( "ParaRegisterModeActive", STYLE,  REGISTER_TRUE,  XML_TYPE_BOOL, 0 ),
     // RES_PARATR_NUMRULE
     MP_E( "NumberingStyleName", STYLE,  LIST_STYLE_NAME,    MID_FLAG_SPECIAL_ITEM|XML_TYPE_STYLENAME, CTF_NUMBERINGSTYLENAME ),
-    MP_E( "NumberingRules",     TEXT,   ENABLE_NUMBERING,   MID_FLAG_NO_PROPERTY|XML_TYPE_BOOL, CTF_ALIEN_ATTRIBUTE_IMPORT ),
 
     // RES_FILL_ORDER
     // not required
commit c9699f82edf67a55f4cfdd885fa779b13d816c87
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 14 11:56:16 2012 +0200

    fdo#49876: ODF export: do not export font-size="0pt"
    
    This is invalid, font size must be positive.
    
    Change-Id: I2425d7c596ca9c7c80c0d24c44cdd9ec1ac1dd80

diff --git a/xmloff/source/style/chrhghdl.cxx b/xmloff/source/style/chrhghdl.cxx
index 8b8f842..0a607ef 100644
--- a/xmloff/source/style/chrhghdl.cxx
+++ b/xmloff/source/style/chrhghdl.cxx
@@ -67,6 +67,7 @@ sal_Bool XMLCharHeightHdl::importXML( const OUString& rStrImpValue, uno::Any& rV
         if (::sax::Converter::convertDouble(fSize, rStrImpValue,
                     eSrcUnit, util::MeasureUnit::POINT))
         {
+            fSize = ::std::max<double>(fSize, 1.0); // fdo#49876: 0pt is invalid
             rValue <<= (float)fSize;
             return sal_True;
         }
@@ -82,6 +83,7 @@ sal_Bool XMLCharHeightHdl::exportXML( OUString& rStrExpValue, const uno::Any& rV
     float fSize = 0;
     if( rValue >>= fSize )
     {
+        fSize = ::std::max<float>(fSize, 1.0f); // fdo#49876: 0pt is invalid
         ::sax::Converter::convertDouble(aOut, (double)fSize, true,
                 util::MeasureUnit::POINT, util::MeasureUnit::POINT);
         aOut.append( sal_Unicode('p'));
commit a2959aba6affa06dc0c6fb19d0c2b73958e6b221
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Sep 13 19:14:22 2012 +0200

    fdo#49678: ODF export: add svg:viewBox to draw:connector
    
    This attribute is mandatory; for the given bugdoc various
    svg:viewBox="0 0 2500 1" are now written.
    
    Change-Id: I7ea2294e0796546dcbb245993c01c2dd2b2a755a

diff --git a/xmloff/source/draw/shapeexport2.cxx b/xmloff/source/draw/shapeexport2.cxx
index 963b3fa..8d04c9d 100644
--- a/xmloff/source/draw/shapeexport2.cxx
+++ b/xmloff/source/draw/shapeexport2.cxx
@@ -1452,6 +1452,24 @@ void XMLShapeExport::ImpExportConnectorShape(
         }
     }
 
+    // get matrix
+    ::basegfx::B2DHomMatrix aMatrix;
+    ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xProps);
+
+    // decompose and correct about pRefPoint
+    ::basegfx::B2DTuple aTRScale;
+    double fTRShear(0.0);
+    double fTRRotate(0.0);
+    ::basegfx::B2DTuple aTRTranslate;
+    ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear,
+            fTRRotate, aTRTranslate, pRefPoint);
+
+    // fdo#49678: create and export ViewBox
+    awt::Point aPoint(0, 0);
+    awt::Size aSize(FRound(aTRScale.getX()), FRound(aTRScale.getY()));
+    SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height);
+    mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
+
     // write connector shape. Add Export later.
     sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
     SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CONNECTOR, bCreateNewline, sal_True);
commit a27a6b68b7e4d2a4674b4de59fc487b17c7c9907
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Sep 13 17:49:20 2012 +0200

    fdo#49677: ODF export: always add xlink:type attribute
    
    The xlink:type was optional on text:a and draw:a elements in ODF 1.1 but
    is mandatory in ODF 1.2
    
    Change-Id: Ifc7301ed1b0120d31a156751888dea1a55e952fe

diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index c649b97..e14eec4 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -1697,6 +1697,7 @@ void XMLTextFieldExport::ExportFieldHelper(
         ProcessString(XML_TARGET_FRAME_NAME,
                       GetStringProperty(sPropertyTargetFrame,rPropSet),
                       sal_True, XML_NAMESPACE_OFFICE);
+        GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
         SvXMLElementExport aUrlField(rExport, XML_NAMESPACE_TEXT, XML_A,
                                      sal_False, sal_False);
         GetExport().Characters(sPresentation);
commit 22b615a7a54e6424bf3a492d2a07573ad9090949
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Sep 13 11:15:13 2012 +0200

    fdo#30711: ODF export: "text:name" is mandatory on bookmarks:
    
    XMLTextParagraphExport: Add a mapping that generates names for those
    field marks that don't have a name so validators don't complain.
    (regression from 7a1c5e54afe4e4ef7e17c2e9c969cd41221edc28)
    There is still the problem that we cannot easily guarantee that the
    names (generated or from some field param) do not clash with the names
    of actual bookmarks...
    
    Change-Id: I9ed65b94b3e8f725db4354222f2565176b32be52

diff --git a/xmloff/inc/xmloff/txtparae.hxx b/xmloff/inc/xmloff/txtparae.hxx
index c5d3e75..284e88f 100644
--- a/xmloff/inc/xmloff/txtparae.hxx
+++ b/xmloff/inc/xmloff/txtparae.hxx
@@ -44,6 +44,7 @@
 #include <xmloff/SinglePropertySetInfoCache.hxx>
 #include <xmloff/XMLStringVector.hxx>
 #include <vector>
+#include <boost/scoped_ptr.hpp>
 
 class XMLTextListsHelper;
 class SvXMLExport;
@@ -76,6 +77,8 @@ namespace xmloff
 
 class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public XMLStyleExport
 {
+    struct Impl;
+    ::boost::scoped_ptr<Impl> m_pImpl;
 
 //  SvXMLExport& rExport;
     SvXMLAutoStylePoolP& rAutoStylePool;
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 6eba38b..83ba6b3 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -1152,11 +1152,36 @@ void XMLTextParagraphExport::exportListChange(
     }
 }
 
+struct XMLTextParagraphExport::Impl
+{
+    typedef ::std::map<Reference<XFormField>, sal_Int32> FieldMarkMap_t;
+    FieldMarkMap_t m_FieldMarkMap;
+
+    explicit Impl() {}
+    sal_Int32 AddFieldMarkStart(Reference<XFormField> const& i_xFieldMark)
+    {
+        assert(m_FieldMarkMap.find(i_xFieldMark) == m_FieldMarkMap.end());
+        sal_Int32 const ret(m_FieldMarkMap.size());
+        m_FieldMarkMap.insert(::std::make_pair(i_xFieldMark, ret));
+        return ret;
+    }
+    sal_Int32 GetFieldMarkIndex(Reference<XFormField> const& i_xFieldMark)
+    {
+        FieldMarkMap_t::const_iterator const it(
+                m_FieldMarkMap.find(i_xFieldMark));
+        // rely on SwXFieldmark::CreateXFieldmark returning the same instance
+        // because the Reference in m_FieldMarkMap will keep it alive
+        assert(it != m_FieldMarkMap.end());
+        return it->second;
+    }
+};
+
 XMLTextParagraphExport::XMLTextParagraphExport(
         SvXMLExport& rExp,
         SvXMLAutoStylePoolP & rASP
         ) :
     XMLStyleExport( rExp, OUString(), &rASP ),
+    m_pImpl(new Impl),
     rAutoStylePool( rASP ),
     pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())),
     pFieldExport( 0 ),
@@ -2178,7 +2203,8 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
         sal_Bool bAutoStyles, sal_Bool bIsProgress,
         sal_Bool bPrvChrIsSpc )
 {
-    static OUString sMeta("InContentMetadata");
+    static const OUString sMeta("InContentMetadata");
+    static const OUString sFieldMarkName("__FieldMark_");
     bool bPrevCharIsSpace = bPrvChrIsSpc;
     bool bAnnotationStarted = false;
 
@@ -2304,16 +2330,22 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
                 {
                     if (xFormField.is())
                     {
+                        OUString sName;
                         Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
                         if (xParameters.is() && xParameters->hasByName("Name"))
                         {
                             const Any aValue = xParameters->getByName("Name");
                             OUString sValue;
-                            if (aValue >>= sValue)
-                            {
-                                GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, sValue);
-                            }
+                            aValue >>= sName;
+                        }
+                        if (sName.isEmpty())
+                        {   // name attribute is mandatory, so have to pull a
+                            // rabbit out of the hat here
+                            sName = sFieldMarkName + OUString::valueOf(
+                                    m_pImpl->AddFieldMarkStart(xFormField));
                         }
+                        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
+                                sName);
                         SvXMLElementExport aElem( GetExport(), !bAutoStyles,
                             XML_NAMESPACE_TEXT, XML_BOOKMARK_START,
                             sal_False, sal_False );
@@ -2358,20 +2390,25 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
                     Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
                     if (xFormField.is())
                     {
+                        OUString sName;
                         Reference< ::com::sun::star::container::XNameAccess > xParameters(xFormField->getParameters(), UNO_QUERY);
                         if (xParameters.is() && xParameters->hasByName("Name"))
                         {
                             const Any aValue = xParameters->getByName("Name");
-                            OUString sValue;
-                            if (aValue >>= sValue)
-                            {
-                                GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, sValue);
-                            }
+                            aValue >>= sName;
                         }
+                        if (sName.isEmpty())
+                        {   // name attribute is mandatory, so have to pull a
+                            // rabbit out of the hat here
+                            sName = sFieldMarkName + OUString::valueOf(
+                                m_pImpl->GetFieldMarkIndex(xFormField));
+                        }
+                        GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME,
+                                sName);
+                        SvXMLElementExport aElem( GetExport(), !bAutoStyles,
+                            XML_NAMESPACE_TEXT, XML_BOOKMARK_END,
+                            sal_False, sal_False );
                     }
-                    SvXMLElementExport aElem( GetExport(), !bAutoStyles,
-                        XML_NAMESPACE_TEXT, XML_BOOKMARK_END,
-                        sal_False, sal_False );
                 }
             }
             else if (sType.equals(sTextFieldStartEnd))
@@ -2401,10 +2438,10 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
                     if (xBookmark.is())
                     {
                         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName());
+                        SvXMLElementExport aElem( GetExport(), !bAutoStyles,
+                            XML_NAMESPACE_TEXT, XML_BOOKMARK,
+                            sal_False, sal_False );
                     }
-                    SvXMLElementExport aElem( GetExport(), !bAutoStyles,
-                        XML_NAMESPACE_TEXT, XML_BOOKMARK,
-                        sal_False, sal_False );
                 }
             }
             else if (sType.equals(sSoftPageBreak))
commit c45c64e3de51d9f56c9d9789729b6f7952547a61
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 12 23:19:57 2012 +0200

    fdo#45700: sw ODF export: workaround corrupted table model:
    
    do not export invalid table:number-columns-spanned="0"
    
    Change-Id: I7e286a9fcb6ed3df7222c83fe73e870e69561649

diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 4acd7eb..5d499b4 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -977,14 +977,9 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
             if ( nCol < nOldCol )
             {
                 OSL_FAIL( "table and/or table information seems to be corrupted." );
-                if ( nBox == nBoxes - 1 )
-                {
-                    nCol = rLines.GetColumns().size() - 1;
-                }
-                else
-                {
-                    nCol = nOldCol;
-                }
+                // NOTE: nOldCol is not necessarily a valid index into
+                // GetColumns(), but that doesn't matter here
+                nCol = nOldCol;
             }
 
             sal_uInt16 nColSpan = nCol - nOldCol + 1U;


More information about the Libreoffice-commits mailing list