[Libreoffice-commits] core.git: 2 commits - include/oox include/sal oox/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Apr 16 09:37:12 PDT 2014


 include/oox/helper/propertymap.hxx                      |    2 
 include/sal/log-areas.dox                               |    1 
 oox/source/drawingml/customshapeproperties.cxx          |    3 
 oox/source/drawingml/customshapes/generatePresetsCXX.pl |   72 +++++++++++++++-
 oox/source/drawingml/shape.cxx                          |    1 
 oox/source/helper/propertymap.cxx                       |   19 ++++
 6 files changed, 97 insertions(+), 1 deletion(-)

New commits:
commit e1f9e73893e3d5760dab45b9322eca9fb8ce7ac4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Apr 16 18:29:46 2014 +0200

    oox: add --data switch to generatePresetsCXX.pl
    
    generatePresetsCXX.pl (as its name says) by default generates C++ code,
    but with the new switch it filters out data from the provided
    custom-shapes.log.
    
    Change-Id: Ic59c666422db667112c280716f98342fabdae692

diff --git a/oox/source/drawingml/customshapes/generatePresetsCXX.pl b/oox/source/drawingml/customshapes/generatePresetsCXX.pl
index 2ce96f5..29a3c19 100755
--- a/oox/source/drawingml/customshapes/generatePresetsCXX.pl
+++ b/oox/source/drawingml/customshapes/generatePresetsCXX.pl
@@ -7,6 +7,54 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 
+sub loadData()
+{
+    open (IN, "<custom-shapes.log");
+
+    my %sources;
+
+    while (<IN>)
+    {
+        if (/==csdata== /)
+        {
+            if (/shape name: '/)
+            {
+                chop;
+                s/.*shape name: '([^']+)'.*/$1/;
+                $name = $_;
+            }
+            else
+            {
+                if (/==csdata== begin/)
+                {
+                    $inside = true;
+                    @code = ();
+                }
+                else
+                {
+                    if (/==csdata== end/)
+                    {
+                        s/^  <\/([^>]+)>/$1/;
+                        undef $inside;
+                        $sources{$name} = [ @code ];
+                    }
+                }
+            }
+        }
+        else
+        {
+            if ($inside)
+            {
+                push @code, $_;
+            }
+        }
+    }
+
+    close (IN);
+
+    return \%sources;
+}
+
 sub loadSourceCode()
 {
     open (IN, "<custom-shapes.log");
@@ -168,6 +216,28 @@ EOS
     close OUT;
 }
 
-generateSource (loadSourceCode ());
+sub generateData
+{
+    my $sources = shift;
+    open (OUT, ">oox-drawingml-cs-presets");
+
+    foreach $shape (sort(keys %$sources))
+    {
+        printf OUT "/* %s */\n", $shape;
+        print OUT @{$sources->{$shape}};
+    }
+
+    close OUT;
+}
+
+my $arg = shift;
+
+if ($arg eq "--data")
+{
+    generateData(loadData());
+} else
+{
+    generateSource (loadSourceCode ());
+}
 
 # vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index c1d00f6..f7150db 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -895,6 +895,7 @@ Reference< XShape > Shape::createAndInsert(
             }
 
             SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'");
+            SAL_INFO("oox.csdata", "==csdata== shape name: '" << msName << "'");
             mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape, maSize );
         }
         else if( getTextBody() )
commit 142d63d01567b5c7e513258f2835dbde54b30012
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Apr 16 18:15:21 2014 +0200

    oox: add a method to dump a PropertyMap as data
    
    It was already possible to dump a PropertyMap as code, but not as data.
    The plan here is that if we dump the customshape preset definitions as
    data, then once there is a parser for it, we can get rid of the ugly
    generated code.
    
    Change-Id: If596941fedf71693e5d0bff436446ac0855c4c84

diff --git a/include/oox/helper/propertymap.hxx b/include/oox/helper/propertymap.hxx
index 4b4f416..5cd606b 100644
--- a/include/oox/helper/propertymap.hxx
+++ b/include/oox/helper/propertymap.hxx
@@ -110,6 +110,8 @@ public:
 #endif
   static void dumpCode( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet);
   void dumpCode();
+  static void dumpData(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> rXPropSet);
+  void dumpData();
 #endif
 private:
     const PropertyNameVector* mpPropNames;
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 90fd1c0..c924dcb 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -173,6 +173,7 @@ certain functionality.
 @li @c filter.tiff
 @li @c filter.xslt - xslt import/export
 @li @c oox.cscode - see oox/source/drawingml/customshapes/README
+ at li @c oox.csdata - see oox/source/drawingml/customshapes/README
 @li @c oox.drawingml - DrawingML
 @li @c oox.ppt - pptx filter
 @li @c oox.storage - ZipStorage class
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 4886912..cfaec25 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -351,6 +351,9 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
         SAL_INFO("oox.cscode", "==cscode== begin");
         aPropertyMap.dumpCode();
         SAL_INFO("oox.cscode", "==cscode== end");
+        SAL_INFO("oox.csdata", "==csdata== begin");
+        aPropertyMap.dumpData();
+        SAL_INFO("oox.csdata", "==csdata== end");
 #endif
         // converting the vector to a sequence
         Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence();
diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx
index 05c3b13..1e5af51 100644
--- a/oox/source/helper/propertymap.cxx
+++ b/oox/source/helper/propertymap.cxx
@@ -27,6 +27,8 @@
 # include <com/sun/star/text/WritingMode.hpp>
 using ::com::sun::star::style::LineSpacing;
 using ::com::sun::star::text::WritingMode;
+#include <comphelper/anytostring.hxx>
+#include <iostream>
 #endif
 
 #include <com/sun/star/beans/PropertyValue.hpp>
@@ -929,10 +931,27 @@ void PropertyMap::dumpCode( Reference< XPropertySet > rXPropSet )
     }
 }
 
+void PropertyMap::dumpData(Reference<XPropertySet> xPropertySet)
+{
+    Reference<XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
+    Sequence<Property> aProperties = xPropertySetInfo->getProperties();
+
+    for (int i = 0; i < aProperties.getLength(); ++i)
+    {
+        std::cerr << aProperties[i].Name << std::endl;
+        std::cerr << comphelper::anyToString(xPropertySet->getPropertyValue(aProperties[i].Name)) << std::endl;
+    }
+}
+
 void PropertyMap::dumpCode()
 {
     dumpCode( Reference< XPropertySet >( makePropertySet(), UNO_QUERY ) );
 }
+
+void PropertyMap::dumpData()
+{
+    dumpData( Reference< XPropertySet >( makePropertySet(), UNO_QUERY ) );
+}
 #endif
 
 } // namespace oox


More information about the Libreoffice-commits mailing list