summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorTzvetelina Tzeneva <tzvetelina@gmail.com>2011-12-22 17:27:32 +0100
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2011-12-22 17:53:53 +0100
commit062eaeffe7cb986255063bb9b0a5f3fb3fc8e34c (patch)
tree0f065352d000a11131203cf6832354bde597ff50 /xmloff
parent61329db01af7fd7c5915a4d81896d52fda7168db (diff)
sw: Improved document comparison based on RSIDs.
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/xmloff/xmltoken.hxx2
-rw-r--r--xmloff/inc/xmloff/xmltypes.hxx1
-rw-r--r--xmloff/inc/xmloff/xmluconv.hxx7
-rw-r--r--xmloff/source/core/xmltoken.cxx2
-rw-r--r--xmloff/source/core/xmluconv.cxx28
-rw-r--r--xmloff/source/style/prhdlfac.cxx3
-rw-r--r--xmloff/source/style/xmlbahdl.cxx42
-rw-r--r--xmloff/source/style/xmlbahdl.hxx12
-rw-r--r--xmloff/source/text/txtprmap.cxx8
9 files changed, 105 insertions, 0 deletions
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index b609dad06faa..3a07e309c999 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -1498,6 +1498,8 @@ namespace xmloff { namespace token {
XML_ROW_HEIGHT,
XML_ROW_NUMBER,
XML_ROWS,
+ XML_RSID,
+ XML_PARRSID,
XML_RUBY,
XML_RUBY_ALIGN,
XML_RUBY_BASE,
diff --git a/xmloff/inc/xmloff/xmltypes.hxx b/xmloff/inc/xmloff/xmltypes.hxx
index 922ad3f340d0..9aee08b6fc59 100644
--- a/xmloff/inc/xmloff/xmltypes.hxx
+++ b/xmloff/inc/xmloff/xmltypes.hxx
@@ -152,6 +152,7 @@
#define XML_TYPE_NEG_PERCENT8 0x00002022 // (100-x)%
#define XML_TYPE_NEG_PERCENT16 0x00002023 // (100-x)
#define XML_TYPE_DOUBLE_PERCENT 0x00002024 // 50% (source is a double from 0.0 to 1.0)
+#define XML_TYPE_HEX 0x00002025 // 00544F1B
// special basic types
#define XML_TYPE_RECTANGLE_LEFT 0x00000100 // the Left member of a awt::Rectangle as a measure
diff --git a/xmloff/inc/xmloff/xmluconv.hxx b/xmloff/inc/xmloff/xmluconv.hxx
index 003fe8c8e021..7e9a460be64c 100644
--- a/xmloff/inc/xmloff/xmluconv.hxx
+++ b/xmloff/inc/xmloff/xmluconv.hxx
@@ -247,6 +247,13 @@ public:
::rtl::OUString encodeStyleName( const ::rtl::OUString& rName,
sal_Bool *pEncoded=0 ) const;
+ /** convert string (hex) to number (sal_uInt32) */
+ static sal_Bool convertHex( sal_uInt32& nVal,
+ const ::rtl::OUString& rValue );
+
+ /** convert number (sal_uInt32) to string (hex) */
+ static void convertHex( ::rtl::OUStringBuffer& rBuffer,
+ sal_uInt32 nVal );
};
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 02970ebf02cc..9ccc67fe94ae 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1503,6 +1503,8 @@ namespace xmloff { namespace token {
TOKEN( "row-height", XML_ROW_HEIGHT ),
TOKEN( "row-number", XML_ROW_NUMBER ),
TOKEN( "rows", XML_ROWS ),
+ TOKEN( "rsid", XML_RSID ),
+ TOKEN( "paragraph-rsid", XML_PARRSID ),
TOKEN( "ruby", XML_RUBY ),
TOKEN( "ruby-align", XML_RUBY_ALIGN ),
TOKEN( "ruby-base", XML_RUBY_BASE ),
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx
index 6ceb8850b014..3ec1a49febeb 100644
--- a/xmloff/source/core/xmluconv.cxx
+++ b/xmloff/source/core/xmluconv.cxx
@@ -931,4 +931,32 @@ OUString SvXMLUnitConverter::encodeStyleName(
return aBuffer.makeStringAndClear();
}
+/** convert string (hex) to number (sal_uInt32) */
+sal_Bool SvXMLUnitConverter::convertHex( sal_uInt32& nVal,
+ const OUString& rValue )
+{
+ if( rValue.getLength() != 8 )
+ return sal_False;
+
+ nVal = 0;
+ for ( int i = 0; i < 8; i++ )
+ {
+ nVal = ( nVal << 4 )
+ | sal::static_int_cast< sal_uInt32 >( lcl_gethex( rValue[i] ) );
+ }
+
+ return sal_True;
+}
+
+/** convert number (sal_uInt32) to string (hex) */
+void SvXMLUnitConverter::convertHex( OUStringBuffer& rBuffer,
+ sal_uInt32 nVal )
+{
+ for ( int i = 0; i < 8; i++ )
+ {
+ rBuffer.append( sal_Unicode( aHexTab[ nVal >> 28 ] ) );
+ nVal <<= 4;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx
index 9e258e8b88d9..a2d2ea18762c 100644
--- a/xmloff/source/style/prhdlfac.cxx
+++ b/xmloff/source/style/prhdlfac.cxx
@@ -210,6 +210,9 @@ const XMLPropertyHandler* XMLPropertyHandlerFactory::CreatePropertyHandler( sal_
case XML_TYPE_COLOR :
pPropHdl = new XMLColorPropHdl;
break;
+ case XML_TYPE_HEX :
+ pPropHdl = new XMLHexPropHdl;
+ break;
case XML_TYPE_NUMBER :
pPropHdl = new XMLNumberPropHdl( 4 );
break;
diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx
index a9f8b147c7f9..b34b37a166fd 100644
--- a/xmloff/source/style/xmlbahdl.cxx
+++ b/xmloff/source/style/xmlbahdl.cxx
@@ -545,6 +545,48 @@ sal_Bool XMLColorPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue,
///////////////////////////////////////////////////////////////////////////////
//
+// class XMLHexPropHdl
+//
+
+XMLHexPropHdl::~XMLHexPropHdl()
+{
+ // Nothing to do
+}
+
+sal_Bool XMLHexPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
+{
+ sal_Bool bRet = sal_False;
+ sal_uInt32 nRsid;
+
+ bRet = SvXMLUnitConverter::convertHex( nRsid, rStrImpValue );
+ rValue <<= nRsid;
+
+ return bRet;
+}
+
+sal_Bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
+{
+ sal_Bool bRet = sal_False;
+ sal_uInt32 nRsid = 0;
+
+ OUStringBuffer aOut;
+ if( rValue >>= nRsid )
+ {
+ SvXMLUnitConverter::convertHex( aOut, nRsid );
+ rStrExpValue = aOut.makeStringAndClear();
+
+ bRet = sal_True;
+ }
+ else
+ {
+ bRet = sal_False;
+ }
+
+ return bRet;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
// class XMLStringPropHdl
//
diff --git a/xmloff/source/style/xmlbahdl.hxx b/xmloff/source/style/xmlbahdl.hxx
index 80f75b0159c7..83b7741b5758 100644
--- a/xmloff/source/style/xmlbahdl.hxx
+++ b/xmloff/source/style/xmlbahdl.hxx
@@ -156,6 +156,18 @@ public:
};
/**
+ PropertyHandler for the XML-data-type: XML_TYPE_HEX
+*/
+class XMLHexPropHdl : public XMLPropertyHandler
+{
+public:
+ virtual ~XMLHexPropHdl();
+
+ virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+ virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+};
+
+/**
PropertyHandler for the XML-data-type: XML_TYPE_STRING
*/
class XMLStringPropHdl : public XMLPropertyHandler
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 6a2582c755b2..29559a6db7dc 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -147,6 +147,10 @@ XMLPropertyMapEntry aXMLParaPropMap[] =
MT_E( "CharUnderlineHasColor", STYLE, TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE, CTF_UNDERLINE_HASCOLOR ),
// RES_CHRATR_WEIGHT
MT_E( "CharWeight", FO, FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT, 0 ),
+ // RES_CHRATR_RSID
+ { "Rsid", sizeof("Rsid")-1, XML_NAMESPACE_OFFICE_EXT, XML_RSID, XML_TYPE_HEX|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFVER_LATEST },
+ // RES_PARATR_RSID
+ { "ParRsid", sizeof("ParRsid")-1, XML_NAMESPACE_OFFICE_EXT, XML_PARRSID, XML_TYPE_HEX|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFVER_LATEST },
// RES_CHRATR_WORDLINEMODE
MT_E( "CharWordMode", STYLE, TEXT_UNDERLINE_MODE, XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY, 0 ),
MT_E( "CharWordMode", STYLE, TEXT_OVERLINE_MODE, XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY, 0 ),
@@ -442,6 +446,10 @@ XMLPropertyMapEntry aXMLTextPropMap[] =
MT_E( "CharUnderlineHasColor", STYLE, TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE, CTF_UNDERLINE_HASCOLOR ),
// RES_CHRATR_WEIGHT
MT_E( "CharWeight", FO, FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT, 0 ),
+ // RES_CHRATR_RSID
+ { "Rsid", sizeof("Rsid")-1, XML_NAMESPACE_OFFICE_EXT, XML_RSID, XML_TYPE_HEX|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFVER_LATEST },
+ // RES_PARATR_RSID
+ { "ParRsid", sizeof("ParRsid")-1, XML_NAMESPACE_OFFICE_EXT, XML_PARRSID, XML_TYPE_HEX|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFVER_LATEST },
// RES_CHRATR_WORDLINEMODE
MT_E( "CharWordMode", STYLE, TEXT_UNDERLINE_MODE, XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY, 0 ),
MT_E( "CharWordMode", STYLE, TEXT_OVERLINE_MODE, XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY, 0 ),