[Libreoffice-commits] core.git: include/oox oox/source
Sarper Akdemir (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 16 12:34:51 UTC 2021
include/oox/export/drawingml.hxx | 18 ++++++
oox/source/export/drawingml.cxx | 108 ++++++++++++++++++++++++++++-----------
2 files changed, 97 insertions(+), 29 deletions(-)
New commits:
commit ba66d49db89678628975b29612c0caab49457adf
Author: Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Wed Jun 9 07:34:32 2021 +0300
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jun 16 14:34:14 2021 +0200
tdf#59323: pptx export: add datetime field type helpers
Creates helper functions to convert from LO time and date formats to datetime
fields on OOXML
Change-Id: Ibbfefa18d0422eddb6c37539294ed23e77fe5f22
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117009
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 2876d59c5367..7f6de9f99006 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -46,6 +46,8 @@
class Graphic;
class SdrObjCustomShape;
+enum class SvxDateFormat;
+enum class SvxTimeFormat;
namespace com::sun::star {
namespace awt {
@@ -166,6 +168,22 @@ protected:
const css::uno::Reference< css::beans::XPropertyState >& rXPropState,
const OUString& aName, css::beans::PropertyState& eState );
OUString GetFieldValue( const css::uno::Reference< css::text::XTextRange >& rRun, bool& bIsURLField );
+ /** Gets OOXML datetime field type from LO Date format
+
+ @param eDate LO Date format
+ */
+ static OUString GetDatetimeTypeFromDate(SvxDateFormat eDate);
+ /** Gets OOXML datetime field type from LO Time format
+
+ @param eTime LO Time format
+ */
+ static OUString GetDatetimeTypeFromTime(SvxTimeFormat eTime);
+ /** Gets OOXML datetime field type from combination of LO Time and Date formats
+
+ @param eDate LO Date format
+ @param eTime LO Time format
+ */
+ static OUString GetDatetimeTypeFromDateTime(SvxDateFormat eDate, SvxTimeFormat eTime);
/// Output the media (including copying a video from vnd.sun.star.Package: to the output if necessary).
void WriteMediaNonVisualProperties(const css::uno::Reference<css::drawing::XShape>& xShape);
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 5f42dc18cd75..26598636efbd 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2286,40 +2286,13 @@ OUString DrawingML::GetFieldValue( const css::uno::Reference< css::text::XTextRa
{
sal_Int32 nNumFmt = -1;
rXPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
- switch(static_cast<SvxDateFormat>(nNumFmt))
- {
- case SvxDateFormat::StdSmall:
- case SvxDateFormat::A: aFieldValue = "datetime"; // 13/02/96
- break;
- case SvxDateFormat::B: aFieldValue = "datetime1"; // 13/02/1996
- break;
- case SvxDateFormat::StdBig:
- case SvxDateFormat::D: aFieldValue = "datetime3"; // 13 February 1996
- break;
- default: break;
- }
+ aFieldValue = GetDatetimeTypeFromDate(static_cast<SvxDateFormat>(nNumFmt));
}
else if(aFieldKind == "ExtTime")
{
sal_Int32 nNumFmt = -1;
rXPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
- switch(static_cast<SvxTimeFormat>(nNumFmt))
- {
- case SvxTimeFormat::Standard:
- case SvxTimeFormat::HH24_MM_SS:
- aFieldValue = "datetime11"; // 13:49:38
- break;
- case SvxTimeFormat::HH24_MM:
- aFieldValue = "datetime10"; // 13:49
- break;
- case SvxTimeFormat::HH12_MM:
- aFieldValue = "datetime12"; // 01:49 PM
- break;
- case SvxTimeFormat::HH12_MM_SS:
- aFieldValue = "datetime13"; // 01:49:38 PM
- break;
- default: break;
- }
+ aFieldValue = GetDatetimeTypeFromTime(static_cast<SvxTimeFormat>(nNumFmt));
}
else if(aFieldKind == "ExtFile")
{
@@ -2346,6 +2319,83 @@ OUString DrawingML::GetFieldValue( const css::uno::Reference< css::text::XTextRa
return aFieldValue;
}
+OUString DrawingML::GetDatetimeTypeFromDate(SvxDateFormat eDate)
+{
+ return GetDatetimeTypeFromDateTime(eDate, SvxTimeFormat::AppDefault);
+}
+
+OUString DrawingML::GetDatetimeTypeFromTime(SvxTimeFormat eTime)
+{
+ return GetDatetimeTypeFromDateTime(SvxDateFormat::AppDefault, eTime);
+}
+
+OUString DrawingML::GetDatetimeTypeFromDateTime(SvxDateFormat eDate, SvxTimeFormat eTime)
+{
+ OUString aDateField;
+ switch (eDate)
+ {
+ case SvxDateFormat::StdSmall:
+ case SvxDateFormat::A:
+ aDateField = "datetime";
+ break;
+ case SvxDateFormat::B:
+ aDateField = "datetime1"; // 13/02/1996
+ break;
+ case SvxDateFormat::StdBig:
+ case SvxDateFormat::C:
+ case SvxDateFormat::D:
+ aDateField = "datetime3"; // 13 February 1996
+ break;
+ case SvxDateFormat::E:
+ case SvxDateFormat::F:
+ aDateField = "datetime2";
+ break;
+ default:
+ break;
+ }
+
+ OUString aTimeField;
+ switch (eTime)
+ {
+ case SvxTimeFormat::Standard:
+ case SvxTimeFormat::HH24_MM_SS:
+ case SvxTimeFormat::HH24_MM_SS_00:
+ aTimeField = "datetime11"; // 13:49:38
+ break;
+ case SvxTimeFormat::HH24_MM:
+ aTimeField = "datetime10"; // 13:49
+ break;
+ case SvxTimeFormat::HH12_MM:
+ case SvxTimeFormat::HH12_MM_AMPM:
+ aTimeField = "datetime12"; // 01:49 PM
+ break;
+ case SvxTimeFormat::HH12_MM_SS:
+ case SvxTimeFormat::HH12_MM_SS_AMPM:
+ case SvxTimeFormat::HH12_MM_SS_00:
+ case SvxTimeFormat::HH12_MM_SS_00_AMPM:
+ aTimeField = "datetime13"; // 01:49:38 PM
+ break;
+ default:
+ break;
+ }
+
+ if (!aDateField.isEmpty() && aTimeField.isEmpty())
+ return aDateField;
+ else if (!aTimeField.isEmpty() && aDateField.isEmpty())
+ return aTimeField;
+ else if (!aDateField.isEmpty() && !aTimeField.isEmpty())
+ {
+ if (aTimeField == "datetime11" || aTimeField == "datetime13")
+ // only datetime format that has Date and HH:MM:SS
+ return "datetime9"; // dd/mm/yyyy H:MM:SS
+ else
+ // only datetime format that has Date and HH:MM
+ return "datetime8"; // dd/mm/yyyy H:MM
+ }
+ else
+ return "";
+}
+
void DrawingML::WriteRun( const Reference< XTextRange >& rRun,
bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet)
More information about the Libreoffice-commits
mailing list