oox: generate data, not code for drawingML export adjustment values

Change-Id: I5898314c630348552ca2e0a6df1cc76972e3974c
This commit is contained in:
Miklos Vajna 2014-04-15 09:35:28 +02:00
parent 05a940f993
commit 2dde1db057
8 changed files with 119 additions and 21 deletions

View File

@ -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 \

View File

@ -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:

16
oox/Package_generated.mk Normal file
View File

@ -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:

View File

@ -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++ )

View File

@ -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: #

View File

@ -124,6 +124,7 @@ $(eval $(call gb_InstallModule_add_scpfiles,scp2/ooo,\
$(if $(filter WNTGCC,$(OS)$(COM)),\
scp2/source/ooo/mingw_dlls \
) \
scp2/source/ooo/module_filter \
))
$(eval $(call gb_InstallModule_add_localized_scpfiles,scp2/ooo,\

View File

@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*/
#include "macros.inc"
Module gid_Module_Filter
Name = "Filter Data";
Description = "Filter Data";
PackageInfo = "packinfo_office.txt";
ParentID = gid_Module_Root_Brand;
Styles = (HIDDEN_ROOT);
Dirs = (gid_Dir_Share_Filter);
Files = (
gid_File_Dat_OoxDrawingmlAdjNames);
End
Directory gid_Dir_Share_Filter
ParentID = gid_Brand_Dir_Share;
DosName = "filter";
End
File gid_File_Dat_OoxDrawingmlAdjNames
TXT_FILE_BODY;
Dir = gid_Dir_Share_Filter;
Name = "oox-drawingml-adj-names";
Styles = (PACKED);
End
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1243,6 +1243,21 @@ destpath = "/opt"
packageversion = "%PACKAGEVERSION"
End
Start
module = "gid_Module_Filter"
solarispackagename = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-filter-data"
solarisrequires = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01 (Name="Core module for %PRODUCTNAME %PRODUCTVERSION"), %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core02 (Name="Core module for %PRODUCTNAME %PRODUCTVERSION"), %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core03 (Name="Core module for %PRODUCTNAME %PRODUCTVERSION"), %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core04 (Name="Core module for %PRODUCTNAME %PRODUCTVERSION"), %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core05 (Name="Core module for %PRODUCTNAME %PRODUCTVERSION"), %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core06 (Name="Core module for %PRODUCTNAME %PRODUCTVERSION"), %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core07 (Name="Core module for %PRODUCTNAME %PRODUCTVERSION")"
packagename = "%BASISPACKAGEPREFIX%PRODUCTVERSION-filter-data"
requires = "%BASISPACKAGEPREFIX%PRODUCTVERSION-core01 %PACKAGEVERSION %PACKAGEVERSION-%PACKAGEREVISION,%BASISPACKAGEPREFIX%PRODUCTVERSION-core02 %PACKAGEVERSION %PACKAGEVERSION-%PACKAGEREVISION,%BASISPACKAGEPREFIX%PRODUCTVERSION-core03 %PACKAGEVERSION %PACKAGEVERSION-%PACKAGEREVISION,%BASISPACKAGEPREFIX%PRODUCTVERSION-core04 %PACKAGEVERSION %PACKAGEVERSION-%PACKAGEREVISION,%BASISPACKAGEPREFIX%PRODUCTVERSION-core05 %PACKAGEVERSION %PACKAGEVERSION-%PACKAGEREVISION,%BASISPACKAGEPREFIX%PRODUCTVERSION-core06 %PACKAGEVERSION %PACKAGEVERSION-%PACKAGEREVISION,%BASISPACKAGEPREFIX%PRODUCTVERSION-core07 %PACKAGEVERSION %PACKAGEVERSION-%PACKAGEREVISION"
linuxpatchrequires = ""
copyright = "2012 The Document Foundation"
solariscopyright = "solariscopyrightfile"
vendor = "The Document Foundation"
description = "Filter data for %PRODUCTNAME %PRODUCTVERSION"
destpath = "/opt"
packageversion = "%PACKAGEVERSION"
End
Start
module = "gid_Module_Reportbuilder"
solarispackagename = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-extension-report-builder"