From 73a270d8c6d1878becacec1fb41db35188447361 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 10 Jan 2014 10:30:52 +0800 Subject: [PATCH] Add merge format API --- src/xlsx/xlsxformat.cpp | 20 ++++++++++++++++++++ src/xlsx/xlsxformat.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/xlsx/xlsxformat.cpp b/src/xlsx/xlsxformat.cpp index abce847..1624798 100755 --- a/src/xlsx/xlsxformat.cpp +++ b/src/xlsx/xlsxformat.cpp @@ -1137,6 +1137,26 @@ bool Format::hasProtectionData() const return false; } +/*! + Merges the current format with the properties described by format \a modifier. + */ +void Format::mergeFormat(const Format &modifier) +{ + if (!modifier.isValid()) + return; + + if (!isValid()) { + d = modifier.d; + return; + } + + QMapIterator it(modifier.d->property); + while(it.hasNext()) { + it.next(); + setProperty(it.key(), it.value()); + } +} + /*! Returns true if the format is valid; otherwise returns false. */ diff --git a/src/xlsx/xlsxformat.h b/src/xlsx/xlsxformat.h index b0e9378..0923d0e 100755 --- a/src/xlsx/xlsxformat.h +++ b/src/xlsx/xlsxformat.h @@ -216,6 +216,7 @@ public: bool hidden() const; void setHidden(bool hidden); + void mergeFormat(const Format &modifier); bool isValid() const; bool isEmpty() const;