Kaydet (Commit) 21661ebf authored tarafından Kohei Yoshida's avatar Kohei Yoshida

fdo#60740: Populate auto styles from edit cells without using UNO API.

Not using UNO API here alone made this code fly.

Change-Id: Ib3eff168bbe49e49fb413909b7a14057f808cdf9
üst 8b3b7e30
...@@ -196,9 +196,10 @@ protected: ...@@ -196,9 +196,10 @@ protected:
SinglePropertySetInfoCache aCharStyleNamesPropInfoCache; SinglePropertySetInfoCache aCharStyleNamesPropInfoCache;
// SvXMLExport& GetExport() { return rExport; } SvXMLAutoStylePoolP& GetAutoStylePool() { return rAutoStylePool; }
// const SvXMLExport& GetExport() const { return rExport; } const SvXMLAutoStylePoolP& GetAutoStylePool() const { return rAutoStylePool; }
public:
UniReference < SvXMLExportPropertyMapper > GetParaPropMapper() const UniReference < SvXMLExportPropertyMapper > GetParaPropMapper() const
{ {
return xParaPropMapper; return xParaPropMapper;
...@@ -226,11 +227,6 @@ protected: ...@@ -226,11 +227,6 @@ protected:
return xRubyPropMapper; return xRubyPropMapper;
} }
SvXMLAutoStylePoolP& GetAutoStylePool() { return rAutoStylePool; }
const SvXMLAutoStylePoolP& GetAutoStylePool() const { return rAutoStylePool; }
public:
OUString FindTextStyleAndHyperlink( OUString FindTextStyleAndHyperlink(
const ::com::sun::star::uno::Reference < const ::com::sun::star::uno::Reference <
::com::sun::star::beans::XPropertySet > & rPropSet, ::com::sun::star::beans::XPropertySet > & rPropSet,
......
...@@ -11,81 +11,81 @@ ...@@ -11,81 +11,81 @@
#include "editeng/eeitem.hxx" #include "editeng/eeitem.hxx"
#include "editeng/memberids.hrc" #include "editeng/memberids.hrc"
#include "xmloff/xmlnmspe.hxx"
static struct { ScXMLEditAttributeMap::Entry aEntries[] = {
const char* mpXMLName;
const char* mpAPIName;
sal_uInt16 mnItemID;
sal_uInt8 mnFlag;
} aEntries[] = { { XML_NAMESPACE_FO, "color", "CharColor", EE_CHAR_COLOR, 0 },
{ XML_NAMESPACE_STYLE, "font-charset", "CharFontCharSet", EE_CHAR_FONTINFO, MID_FONT_CHAR_SET },
{ "color", "CharColor", EE_CHAR_COLOR, 0 }, { XML_NAMESPACE_STYLE, "font-charset-asian", "CharFontCharSetAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_CHAR_SET },
{ "font-charset", "CharFontCharSet", EE_CHAR_FONTINFO, MID_FONT_CHAR_SET }, { XML_NAMESPACE_STYLE, "font-charset-complex", "CharFontCharSetComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_CHAR_SET },
{ "font-charset-asian", "CharFontCharSetAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_CHAR_SET }, { XML_NAMESPACE_FO, "font-family", "CharFontName", EE_CHAR_FONTINFO, MID_FONT_FAMILY_NAME },
{ "font-charset-complex", "CharFontCharSetComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_CHAR_SET }, { XML_NAMESPACE_STYLE, "font-family-asian", "CharFontNameAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_FAMILY_NAME },
{ "font-family", "CharFontName", EE_CHAR_FONTINFO, MID_FONT_FAMILY_NAME }, { XML_NAMESPACE_STYLE, "font-family-complex", "CharFontNameAsian", EE_CHAR_FONTINFO_CTL, MID_FONT_FAMILY_NAME },
{ "font-family-asian", "CharFontNameAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_FAMILY_NAME }, { XML_NAMESPACE_STYLE, "font-family-generic", "CharFontFamily", EE_CHAR_FONTINFO, MID_FONT_FAMILY },
{ "font-family-complex", "CharFontNameAsian", EE_CHAR_FONTINFO_CTL, MID_FONT_FAMILY_NAME }, { XML_NAMESPACE_STYLE, "font-family-generic-asian", "CharFontFamilyAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_FAMILY },
{ "font-family-generic", "CharFontFamily", EE_CHAR_FONTINFO, MID_FONT_FAMILY }, { XML_NAMESPACE_STYLE, "font-family-generic-complex", "CharFontFamilyComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_FAMILY },
{ "font-family-generic-asian", "CharFontFamilyAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_FAMILY }, { XML_NAMESPACE_STYLE, "font-pitch", "CharFontPitch", EE_CHAR_FONTINFO, MID_FONT_PITCH },
{ "font-family-generic-complex", "CharFontFamilyComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_FAMILY }, { XML_NAMESPACE_STYLE, "font-pitch-asian", "CharFontPitchAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_PITCH },
{ "font-pitch", "CharFontPitch", EE_CHAR_FONTINFO, MID_FONT_PITCH }, { XML_NAMESPACE_STYLE, "font-pitch-complex", "CharFontPitchComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_PITCH },
{ "font-pitch-asian", "CharFontPitchAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_PITCH }, { XML_NAMESPACE_FO, "font-size", "CharHeight", EE_CHAR_FONTHEIGHT, MID_FONTHEIGHT },
{ "font-pitch-complex", "CharFontPitchComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_PITCH }, { XML_NAMESPACE_STYLE, "font-size-asian", "CharHeightAsian", EE_CHAR_FONTHEIGHT_CJK, MID_FONTHEIGHT },
{ "font-size", "CharHeight", EE_CHAR_FONTHEIGHT, MID_FONTHEIGHT }, { XML_NAMESPACE_STYLE, "font-size-complex", "CharHeightComplex", EE_CHAR_FONTHEIGHT_CTL, MID_FONTHEIGHT },
{ "font-size-asian", "CharHeightAsian", EE_CHAR_FONTHEIGHT_CJK, MID_FONTHEIGHT }, { XML_NAMESPACE_FO, "font-style", "CharPosture", EE_CHAR_ITALIC, MID_POSTURE },
{ "font-size-complex", "CharHeightComplex", EE_CHAR_FONTHEIGHT_CTL, MID_FONTHEIGHT }, { XML_NAMESPACE_STYLE, "font-style-asian", "CharPostureAsian", EE_CHAR_ITALIC_CJK, MID_POSTURE },
{ "font-style", "CharPosture", EE_CHAR_ITALIC, MID_POSTURE }, { XML_NAMESPACE_STYLE, "font-style-complex", "CharPostureComplex", EE_CHAR_ITALIC_CTL, MID_POSTURE },
{ "font-style-asian", "CharPostureAsian", EE_CHAR_ITALIC_CJK, MID_POSTURE }, { XML_NAMESPACE_STYLE, "font-style-name", "CharFontStyleName", EE_CHAR_FONTINFO, MID_FONT_STYLE_NAME },
{ "font-style-complex", "CharPostureComplex", EE_CHAR_ITALIC_CTL, MID_POSTURE }, { XML_NAMESPACE_STYLE, "font-style-name-asian", "CharFontStyleNameAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_STYLE_NAME },
{ "font-style-name", "CharFontStyleName", EE_CHAR_FONTINFO, MID_FONT_STYLE_NAME }, { XML_NAMESPACE_STYLE, "font-style-name-complex", "CharFontStyleNameComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_STYLE_NAME },
{ "font-style-name-asian", "CharFontStyleNameAsian", EE_CHAR_FONTINFO_CJK, MID_FONT_STYLE_NAME }, { XML_NAMESPACE_FO, "font-weight", "CharWeight", EE_CHAR_WEIGHT, MID_WEIGHT },
{ "font-style-name-complex", "CharFontStyleNameComplex", EE_CHAR_FONTINFO_CTL, MID_FONT_STYLE_NAME }, { XML_NAMESPACE_STYLE, "font-weight-asian", "CharWeightAsian", EE_CHAR_WEIGHT_CJK, MID_WEIGHT },
{ "font-weight", "CharWeight", EE_CHAR_WEIGHT, MID_WEIGHT }, { XML_NAMESPACE_STYLE, "font-weight-complex", "CharWeightComplex", EE_CHAR_WEIGHT_CTL, MID_WEIGHT },
{ "font-weight-asian", "CharWeightAsian", EE_CHAR_WEIGHT_CJK, MID_WEIGHT }, { XML_NAMESPACE_STYLE, "text-overline-width", "CharOverline", EE_CHAR_OVERLINE, MID_TL_STYLE },
{ "font-weight-complex", "CharWeightComplex", EE_CHAR_WEIGHT_CTL, MID_WEIGHT }, { XML_NAMESPACE_STYLE, "text-overline-color", "CharOverlineColor", EE_CHAR_OVERLINE, MID_TL_COLOR },
{ "text-overline-width", "CharOverline", EE_CHAR_OVERLINE, MID_TL_STYLE }, { XML_NAMESPACE_STYLE, "text-overline-color", "CharOverlineHasColor", EE_CHAR_OVERLINE, MID_TL_HASCOLOR },
{ "text-overline-color", "CharOverlineColor", EE_CHAR_OVERLINE, MID_TL_COLOR }, { XML_NAMESPACE_STYLE, "text-underline-width", "CharUnderline", EE_CHAR_UNDERLINE, MID_TL_STYLE },
{ "text-overline-color", "CharOverlineHasColor", EE_CHAR_OVERLINE, MID_TL_HASCOLOR }, { XML_NAMESPACE_STYLE, "text-underline-color", "CharUnderlineColor", EE_CHAR_UNDERLINE, MID_TL_COLOR },
{ "text-underline-width", "CharUnderline", EE_CHAR_UNDERLINE, MID_TL_STYLE }, { XML_NAMESPACE_STYLE, "text-underline-color", "CharUnderlineHasColor", EE_CHAR_UNDERLINE, MID_TL_HASCOLOR },
{ "text-underline-color", "CharUnderlineColor", EE_CHAR_UNDERLINE, MID_TL_COLOR }, { XML_NAMESPACE_STYLE, "text-line-through-mode", "CharWordMode", EE_CHAR_WLM, 0 },
{ "text-underline-color", "CharUnderlineHasColor", EE_CHAR_UNDERLINE, MID_TL_HASCOLOR }, { XML_NAMESPACE_STYLE, "text-line-through-type", "CharStrikeout", EE_CHAR_STRIKEOUT, MID_CROSS_OUT },
{ "text-line-through-mode", "CharWordMode", EE_CHAR_WLM, 0 }, { XML_NAMESPACE_STYLE, "font-relief", "CharRelief", EE_CHAR_RELIEF, MID_RELIEF },
{ "text-line-through-type", "CharStrikeout", EE_CHAR_STRIKEOUT, MID_CROSS_OUT }, { XML_NAMESPACE_STYLE, "text-outline", "CharContoured", EE_CHAR_OUTLINE, 0 },
{ "font-relief", "CharRelief", EE_CHAR_RELIEF, MID_RELIEF }, { XML_NAMESPACE_FO, "text-shadow", "CharShadowed", EE_CHAR_SHADOW, 0 },
{ "text-outline", "CharContoured", EE_CHAR_OUTLINE, 0 }, { XML_NAMESPACE_FO, "letter-spacing", "CharKerning", EE_CHAR_KERNING, 0 },
{ "text-shadow", "CharShadowed", EE_CHAR_SHADOW, 0 }, { XML_NAMESPACE_STYLE, "letter-kerning", "CharAutoKerning", EE_CHAR_PAIRKERNING, 0 },
{ "letter-spacing", "CharKerning", EE_CHAR_KERNING, 0 }, { XML_NAMESPACE_STYLE, "text-scale", "CharScaleWidth", EE_CHAR_FONTWIDTH, 0 },
{ "letter-kerning", "CharAutoKerning", EE_CHAR_PAIRKERNING, 0 }, { XML_NAMESPACE_STYLE, "text-position", "CharEscapement", EE_CHAR_ESCAPEMENT, MID_ESC },
{ "text-scale", "CharScaleWidth", EE_CHAR_FONTWIDTH, 0 }, { XML_NAMESPACE_STYLE, "text-position", "CharEscapementHeight", EE_CHAR_ESCAPEMENT, MID_ESC_HEIGHT },
{ "text-position", "CharEscapement", EE_CHAR_ESCAPEMENT, MID_ESC }, { XML_NAMESPACE_STYLE, "text-emphasize", "CharEmphasis", EE_CHAR_EMPHASISMARK, MID_EMPHASIS },
{ "text-position", "CharEscapementHeight", EE_CHAR_ESCAPEMENT, MID_ESC_HEIGHT }, { XML_NAMESPACE_FO, "country", "CharLocale", EE_CHAR_LANGUAGE, MID_LANG_LOCALE },
{ "text-emphasize", "CharEmphasis", EE_CHAR_EMPHASISMARK, MID_EMPHASIS }, { XML_NAMESPACE_STYLE, "country-asian", "CharLocaleAsian", EE_CHAR_LANGUAGE_CJK, MID_LANG_LOCALE },
{ "country", "CharLocale", EE_CHAR_LANGUAGE, MID_LANG_LOCALE }, { XML_NAMESPACE_STYLE, "country-complex", "CharLocaleComplex", EE_CHAR_LANGUAGE_CTL, MID_LANG_LOCALE },
{ "country-asian", "CharLocaleAsian", EE_CHAR_LANGUAGE_CJK, MID_LANG_LOCALE },
{ "country-complex", "CharLocaleComplex", EE_CHAR_LANGUAGE_CTL, MID_LANG_LOCALE },
}; };
ScXMLEditAttributeMap::Entry::Entry(sal_uInt16 nItemID, sal_uInt8 nFlag) :
mnItemID(nItemID), mnFlag(nFlag) {}
ScXMLEditAttributeMap::ScXMLEditAttributeMap() ScXMLEditAttributeMap::ScXMLEditAttributeMap()
{ {
size_t n = sizeof(aEntries) / sizeof(aEntries[0]); size_t n = sizeof(aEntries) / sizeof(aEntries[0]);
for (size_t i = 0; i < n; ++i) for (size_t i = 0; i < n; ++i)
{ {
maEntries.insert( maAPIEntries.insert(
EntriesType::value_type( StrToEntriesType::value_type(
OUString::createFromAscii(aEntries[i].mpAPIName), OUString::createFromAscii(aEntries[i].mpAPIName), &aEntries[i]));
Entry(aEntries[i].mnItemID, aEntries[i].mnFlag)));
maItemIDEntries.insert(
IndexToEntriesType::value_type(aEntries[i].mnItemID, &aEntries[i]));
} }
} }
const ScXMLEditAttributeMap::Entry* ScXMLEditAttributeMap::getEntry(const OUString& rXMLName) const const ScXMLEditAttributeMap::Entry* ScXMLEditAttributeMap::getEntryByAPIName(const OUString& rAPIName) const
{
StrToEntriesType::const_iterator it = maAPIEntries.find(rAPIName);
return it == maAPIEntries.end() ? NULL : it->second;
}
const ScXMLEditAttributeMap::Entry* ScXMLEditAttributeMap::getEntryByItemID(sal_uInt16 nItemID) const
{ {
EntriesType::const_iterator it = maEntries.find(rXMLName); IndexToEntriesType::const_iterator it = maItemIDEntries.find(nItemID);
return it == maEntries.end() ? NULL : &it->second; return it == maItemIDEntries.end() ? NULL : it->second;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -23,19 +23,23 @@ class ScXMLEditAttributeMap ...@@ -23,19 +23,23 @@ class ScXMLEditAttributeMap
public: public:
struct Entry struct Entry
{ {
sal_uInt16 nmXMLNS;
const char* mpXMLName;
const char* mpAPIName;
sal_uInt16 mnItemID; sal_uInt16 mnItemID;
sal_uInt8 mnFlag; sal_uInt8 mnFlag;
Entry(sal_uInt16 nItemID, sal_uInt8 nFlag);
}; };
ScXMLEditAttributeMap(); ScXMLEditAttributeMap();
const Entry* getEntry(const OUString& rXMLName) const; const Entry* getEntryByAPIName(const OUString& rAPIName) const;
const Entry* getEntryByItemID(sal_uInt16 nItemID) const;
private: private:
typedef boost::unordered_map<OUString, Entry, OUStringHash> EntriesType; typedef boost::unordered_map<OUString, const Entry*, OUStringHash> StrToEntriesType;
EntriesType maEntries; typedef boost::unordered_map<sal_uInt16, const Entry*> IndexToEntriesType;
StrToEntriesType maAPIEntries;
IndexToEntriesType maItemIDEntries;
}; };
#endif #endif
......
...@@ -419,7 +419,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons ...@@ -419,7 +419,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, cons
continue; continue;
const OUString& rName = xMapper->GetEntryAPIName(it->mnIndex); const OUString& rName = xMapper->GetEntryAPIName(it->mnIndex);
const ScXMLEditAttributeMap::Entry* pEntry = rEditAttrMap.getEntry(rName); const ScXMLEditAttributeMap::Entry* pEntry = rEditAttrMap.getEntryByAPIName(rName);
if (!pEntry) if (!pEntry)
continue; continue;
......
...@@ -34,6 +34,7 @@ namespace com { namespace sun { namespace star { ...@@ -34,6 +34,7 @@ namespace com { namespace sun { namespace star {
} } } } } }
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <boost/scoped_ptr.hpp>
class ScOutlineArray; class ScOutlineArray;
class SvXMLExportPropertyMapper; class SvXMLExportPropertyMapper;
...@@ -58,6 +59,7 @@ class SfxItemPool; ...@@ -58,6 +59,7 @@ class SfxItemPool;
class ScAddress; class ScAddress;
class ScXMLCachedRowAttrAccess; class ScXMLCachedRowAttrAccess;
class ScRangeName; class ScRangeName;
class ScXMLEditAttributeMap;
typedef std::vector< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > > ScMyXShapesVec; typedef std::vector< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > > ScMyXShapesVec;
...@@ -70,6 +72,7 @@ class ScXMLExport : public SvXMLExport ...@@ -70,6 +72,7 @@ class ScXMLExport : public SvXMLExport
com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xSourceStream; com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xSourceStream;
sal_Int32 nSourceStreamPos; sal_Int32 nSourceStreamPos;
mutable boost::scoped_ptr<ScXMLEditAttributeMap> mpEditAttrMap;
UniReference < XMLPropertyHandlerFactory > xScPropHdlFactory; UniReference < XMLPropertyHandlerFactory > xScPropHdlFactory;
UniReference < XMLPropertySetMapper > xCellStylesPropertySetMapper; UniReference < XMLPropertySetMapper > xCellStylesPropertySetMapper;
UniReference < XMLPropertySetMapper > xColumnStylesPropertySetMapper; UniReference < XMLPropertySetMapper > xColumnStylesPropertySetMapper;
...@@ -149,7 +152,7 @@ class ScXMLExport : public SvXMLExport ...@@ -149,7 +152,7 @@ class ScXMLExport : public SvXMLExport
void CloseHeaderColumn(); void CloseHeaderColumn();
void ExportColumns(const sal_Int32 nTable, const com::sun::star::table::CellRangeAddress& aColumnHeaderRange, const bool bHasColumnHeader); void ExportColumns(const sal_Int32 nTable, const com::sun::star::table::CellRangeAddress& aColumnHeaderRange, const bool bHasColumnHeader);
void ExportExternalRefCacheStyles(); void ExportExternalRefCacheStyles();
void ExportCellTextAutoStyles(const com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& xTable); void ExportCellTextAutoStyles(sal_Int32 nTable);
void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow, void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet); const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet);
void WriteRowContent(); void WriteRowContent();
...@@ -218,6 +221,8 @@ class ScXMLExport : public SvXMLExport ...@@ -218,6 +221,8 @@ class ScXMLExport : public SvXMLExport
void CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset, sal_Int32& rNewStart, sal_Int32& rNewEnd ); void CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset, sal_Int32& rNewStart, sal_Int32& rNewEnd );
const ScXMLEditAttributeMap& GetEditAttributeMap() const;
protected: protected:
virtual SvXMLAutoStylePoolP* CreateAutoStylePool(); virtual SvXMLAutoStylePoolP* CreateAutoStylePool();
virtual XMLPageExport* CreatePageExport(); virtual XMLPageExport* CreatePageExport();
......
...@@ -366,7 +366,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray( ...@@ -366,7 +366,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
Sequence < PropertyState > aStates; Sequence < PropertyState > aStates;
const PropertyState *pStates = 0; const PropertyState *pStates = 0;
Reference< XPropertyState > xPropState( rPropSet, UNO_QUERY ); Reference< XPropertyState > xPropState( rPropSet, UNO_QUERY );
if( xPropState.is() ) if( xPropState.is() )
{ {
aStates = xPropState->getPropertyStates( rApiNames ); aStates = xPropState->getPropertyStates( rApiNames );
pStates = aStates.getConstArray(); pStates = aStates.getConstArray();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment