summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-04-15 09:35:28 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-04-15 10:10:51 +0200
commit2dde1db05700df2f8a2c2be0e451a42e091cbbfc (patch)
tree8ca597213321b277b09f43a413c06ba2e2b6258a /oox
parent05a940f993dfdd9546c8108526a483c1d6e6377c (diff)
oox: generate data, not code for drawingML export adjustment values
Change-Id: I5898314c630348552ca2e0a6df1cc76972e3974c
Diffstat (limited to 'oox')
-rw-r--r--oox/CustomTarget_generated.mk10
-rw-r--r--oox/Module_oox.mk1
-rw-r--r--oox/Package_generated.mk16
-rw-r--r--oox/source/export/drawingml.cxx30
-rw-r--r--oox/source/export/preset-definitions-to-shape-types.pl32
5 files changed, 68 insertions, 21 deletions
diff --git a/oox/CustomTarget_generated.mk b/oox/CustomTarget_generated.mk
index 1e7408ae2507..0b81f11eb9f4 100644
--- a/oox/CustomTarget_generated.mk
+++ b/oox/CustomTarget_generated.mk
@@ -23,6 +23,15 @@ $(oox_MISC)/vmlexport-shape-types.cxx : \
mkdir -p $(dir $@)
perl $^ > $@.in_progress 2> $@.log && mv $@.in_progress $@
+$(oox_MISC)/oox-drawingml-adj-names : \
+ $(SRCDIR)/oox/source/export/preset-definitions-to-shape-types.pl \
+ $(SRCDIR)/oox/source/drawingml/customshapes/presetShapeDefinitions.xml \
+ $(SRCDIR)/oox/source/export/presetTextWarpDefinitions.xml \
+ $(SRCDIR)/oox/CustomTarget_generated.mk
+ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,PRL,1)
+ mkdir -p $(dir $@)
+ perl $< --drawingml-adj-names-data $(filter-out $<,$^) > $@.in_progress 2> $@.log && mv $@.in_progress $@
+
$(oox_INC)/tokenhash.inc : $(oox_MISC)/tokenhash.gperf
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,GPF,1)
$(GPERF) --compare-strncmp --switch=2 --readonly-tables $< | sed -e 's/(char\*)0/(char\*)0, 0/g' | grep -v '^#line' > $@
@@ -50,6 +59,7 @@ $(eval $(call oox_GenTarget,tokens,token,tokenhash.gperf))
$(call gb_CustomTarget_get_target,oox/generated) : \
$(oox_MISC)/vmlexport-shape-types.cxx \
+ $(oox_MISC)/oox-drawingml-adj-names \
$(oox_INC)/tokenhash.inc \
$(oox_INC)/tokennames.inc \
$(oox_INC)/namespacenames.inc \
diff --git a/oox/Module_oox.mk b/oox/Module_oox.mk
index c086254b9218..8556f4e1bbcd 100644
--- a/oox/Module_oox.mk
+++ b/oox/Module_oox.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_Module_Module,oox))
$(eval $(call gb_Module_add_targets,oox,\
CustomTarget_generated \
Library_oox \
+ Package_generated \
))
# vim: set noet sw=4 ts=4:
diff --git a/oox/Package_generated.mk b/oox/Package_generated.mk
new file mode 100644
index 000000000000..e23366292ecf
--- /dev/null
+++ b/oox/Package_generated.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Package_Package,oox_generated,$(call gb_CustomTarget_get_workdir,oox/generated)))
+
+$(eval $(call gb_Package_add_files,oox_generated,$(LIBO_SHARE_FOLDER)/filter,\
+ misc/oox-drawingml-adj-names \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a99430a149e6..ff5ad3d75ca4 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <config_folders.h>
+#include "rtl/bootstrap.hxx"
#include "oox/core/xmlfilterbase.hxx"
#include "oox/export/drawingml.hxx"
#include "oox/export/utils.hxx"
@@ -101,9 +103,6 @@ using ::sax_fastparser::FSHelperPtr;
DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet));
-// Defined in generated code.
-extern std::map< OString, std::vector<OString> > ooxDrawingMLGetAdjNames();
-
namespace oox {
namespace drawingml {
@@ -1789,9 +1788,30 @@ void DrawingML::WritePresetShape( const char* pShape )
mpFS->endElementNS( XML_a, XML_prstGeom );
}
+std::map< OString, std::vector<OString> > lcl_getAdjNames()
+{
+ std::map< OString, std::vector<OString> > aRet;
+
+ OUString aPath("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/filter/oox-drawingml-adj-names");
+ rtl::Bootstrap::expandMacros(aPath);
+ SvFileStream aStream(aPath, STREAM_READ);
+ if (aStream.GetError() != ERRCODE_NONE)
+ SAL_WARN("oox", "failed to open oox-drawingml-adj-names");
+ OString aLine;
+ bool bNotDone = aStream.ReadLine(aLine);
+ while (bNotDone)
+ {
+ OString aKey = aLine.getToken(0, '\t');
+ OString aValue = aLine.getToken(1, '\t');
+ aRet[aKey].push_back(aValue);
+ bNotDone = aStream.ReadLine(aLine);
+ }
+ return aRet;
+}
+
void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const PropertyValue& rProp )
{
- static std::map< OString, std::vector<OString> > aAdjMap = ooxDrawingMLGetAdjNames();
+ static std::map< OString, std::vector<OString> > aAdjMap = lcl_getAdjNames();
// If there are predefined adj names for this shape type, look them up now.
std::vector<OString> aAdjustments;
if (aAdjMap.find(OString(pShape)) != aAdjMap.end())
@@ -1813,7 +1833,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b
EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
sal_Int32 nValue, nLength = aAdjustmentSeq.getLength();
- //aAdjustments will give info about the number of adj values for a particular geomtery.For example for hexagon aAdjustments.size() will be 2 and for circular arrow it will be 5 as per ooxDrawingMLGetAdjNames.
+ //aAdjustments will give info about the number of adj values for a particular geomtery.For example for hexagon aAdjustments.size() will be 2 and for circular arrow it will be 5 as per lcl_getAdjNames.
if(aAdjustments.size() == static_cast<sal_uInt32>(nLength))// In case there is a mismatch do not write the XML_gd tag.
{
for( sal_Int32 i=0; i < nLength; i++ )
diff --git a/oox/source/export/preset-definitions-to-shape-types.pl b/oox/source/export/preset-definitions-to-shape-types.pl
index 8f5904d791e8..005d9cdc5e21 100644
--- a/oox/source/export/preset-definitions-to-shape-types.pl
+++ b/oox/source/export/preset-definitions-to-shape-types.pl
@@ -46,7 +46,12 @@ sub show_call_stack
print STDERR "--- End stack trace ---\n";
}
+my $drawingml_adj_names_data = 0;
my $src_shapes = shift;
+if ($src_shapes eq "--drawingml-adj-names-data") {
+ $drawingml_adj_names_data = 1;
+ $src_shapes = shift;
+}
my $src_text = shift;
usage() if ( !defined( $src_shapes ) || !defined( $src_text ) ||
@@ -1187,6 +1192,17 @@ if ( !defined( $result_shapes{'textBox'} ) ) {
}
# Generate the code
+if ($drawingml_adj_names_data eq 1) {
+ foreach my $adj_name (keys %adj_names)
+ {
+ foreach my $adj (@{$adj_names{$adj_name}})
+ {
+ print "$adj_name\t$adj\n";
+ }
+ }
+ exit 0;
+}
+
print <<EOF;
// Shape types generated from
// '$src_shapes'
@@ -1231,22 +1247,6 @@ for ( my $i = 0; $i < 203; ++$i ) {
print <<EOF;
};
-std::map< OString, std::vector<OString> > ooxDrawingMLGetAdjNames()
-{
- std::map< OString, std::vector<OString> > aMap;
-EOF
-
-foreach my $adj_name (keys %adj_names)
-{
- foreach my $adj (@{$adj_names{$adj_name}})
- {
- print " aMap[\"$adj_name\"].push_back(\"$adj\");\n";
- }
-}
-
-print <<EOF;
- return aMap;
-}
EOF
# vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #