Kaydet (Commit) 45a6fdad authored tarafından Jakub Trzebiatowski's avatar Jakub Trzebiatowski Kaydeden (comit) Miklos Vajna

sw UNO Cell Style family, SwXTextCellStyle

Cell Family :: getByName
Cell Family :: getElementNames
Cell Family :: getCount

Change-Id: I37d567ee284054f847c704d9fce370d174a0c48c
Reviewed-on: https://gerrit.libreoffice.org/25896Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 93490816
...@@ -38,6 +38,7 @@ enum class SfxStyleFamily { ...@@ -38,6 +38,7 @@ enum class SfxStyleFamily {
Page = 0x08, Page = 0x08,
Pseudo = 0x10, Pseudo = 0x10,
Table = 0x20, Table = 0x20,
Cell = 0x40,
All = 0x7fff All = 0x7fff
}; };
......
...@@ -32,6 +32,7 @@ namespace nsSwGetPoolIdFromName ...@@ -32,6 +32,7 @@ namespace nsSwGetPoolIdFromName
const SwGetPoolIdFromName GET_POOLID_PAGEDESC = 0x08; const SwGetPoolIdFromName GET_POOLID_PAGEDESC = 0x08;
const SwGetPoolIdFromName GET_POOLID_NUMRULE = 0x10; const SwGetPoolIdFromName GET_POOLID_NUMRULE = 0x10;
const SwGetPoolIdFromName GET_POOLID_TABSTYLE = 0x20; const SwGetPoolIdFromName GET_POOLID_TABSTYLE = 0x20;
const SwGetPoolIdFromName GET_POOLID_CELLSTYLE= 0x40;
} }
#endif #endif
......
...@@ -94,6 +94,7 @@ protected: ...@@ -94,6 +94,7 @@ protected:
*m_pPageDescUINameArray, *m_pPageDescUINameArray,
*m_pNumRuleUINameArray, *m_pNumRuleUINameArray,
*m_pTableStyleUINameArray, *m_pTableStyleUINameArray,
*m_pCellStyleUINameArray,
// Programmatic Name tables // Programmatic Name tables
*m_pTextProgNameArray, *m_pTextProgNameArray,
*m_pListsProgNameArray, *m_pListsProgNameArray,
...@@ -106,7 +107,8 @@ protected: ...@@ -106,7 +107,8 @@ protected:
*m_pHTMLChrFormatProgNameArray, *m_pHTMLChrFormatProgNameArray,
*m_pPageDescProgNameArray, *m_pPageDescProgNameArray,
*m_pNumRuleProgNameArray, *m_pNumRuleProgNameArray,
*m_pTableStyleProgNameArray; *m_pTableStyleProgNameArray,
*m_pCellStyleProgNameArray;
static NameToIdHash *m_pParaUIMap, static NameToIdHash *m_pParaUIMap,
*m_pCharUIMap, *m_pCharUIMap,
...@@ -114,13 +116,15 @@ protected: ...@@ -114,13 +116,15 @@ protected:
*m_pFrameUIMap, *m_pFrameUIMap,
*m_pNumRuleUIMap, *m_pNumRuleUIMap,
*m_pTableStyleUIMap, *m_pTableStyleUIMap,
*m_pCellStyleUIMap,
*m_pParaProgMap, *m_pParaProgMap,
*m_pCharProgMap, *m_pCharProgMap,
*m_pPageProgMap, *m_pPageProgMap,
*m_pFrameProgMap, *m_pFrameProgMap,
*m_pNumRuleProgMap, *m_pNumRuleProgMap,
*m_pTableStyleProgMap; *m_pTableStyleProgMap,
*m_pCellStyleProgMap;
static void fillNameFromId(sal_uInt16 nId, OUString &rName, bool bProgName); static void fillNameFromId(sal_uInt16 nId, OUString &rName, bool bProgName);
static const OUString& getNameFromId(sal_uInt16 nId, const OUString &rName, static const OUString& getNameFromId(sal_uInt16 nId, const OUString &rName,
...@@ -181,6 +185,7 @@ public: ...@@ -181,6 +185,7 @@ public:
static const ::std::vector<OUString>& GetPageDescUINameArray(); static const ::std::vector<OUString>& GetPageDescUINameArray();
static const ::std::vector<OUString>& GetNumRuleUINameArray(); static const ::std::vector<OUString>& GetNumRuleUINameArray();
static const ::std::vector<OUString>& GetTableStyleUINameArray(); static const ::std::vector<OUString>& GetTableStyleUINameArray();
static const ::std::vector<OUString>& GetCellStyleUINameArray();
static const ::std::vector<OUString>& GetTextProgNameArray(); static const ::std::vector<OUString>& GetTextProgNameArray();
static const ::std::vector<OUString>& GetListsProgNameArray(); static const ::std::vector<OUString>& GetListsProgNameArray();
...@@ -194,6 +199,7 @@ public: ...@@ -194,6 +199,7 @@ public:
static const ::std::vector<OUString>& GetPageDescProgNameArray(); static const ::std::vector<OUString>& GetPageDescProgNameArray();
static const ::std::vector<OUString>& GetNumRuleProgNameArray(); static const ::std::vector<OUString>& GetNumRuleProgNameArray();
static const ::std::vector<OUString>& GetTableStyleProgNameArray(); static const ::std::vector<OUString>& GetTableStyleProgNameArray();
static const ::std::vector<OUString>& GetCellStyleProgNameArray();
}; };
#endif // _NAME_MAPPER_HXX #endif // _NAME_MAPPER_HXX
......
...@@ -37,6 +37,7 @@ class SwTextFormatColl; ...@@ -37,6 +37,7 @@ class SwTextFormatColl;
class SwFrameFormat; class SwFrameFormat;
class SwNumRule; class SwNumRule;
class SwTableAutoFormat; class SwTableAutoFormat;
class SwBoxAutoFormat;
// Temporary StyleSheet. // Temporary StyleSheet.
class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase
...@@ -50,6 +51,7 @@ class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase ...@@ -50,6 +51,7 @@ class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase
const SwPageDesc* pDesc; const SwPageDesc* pDesc;
const SwNumRule* pNumRule; const SwNumRule* pNumRule;
const SwTableAutoFormat* pTableFormat; const SwTableAutoFormat* pTableFormat;
const SwBoxAutoFormat* pBoxFormat;
SwDoc& rDoc; SwDoc& rDoc;
SfxItemSet aCoreSet; SfxItemSet aCoreSet;
......
...@@ -78,6 +78,7 @@ const sal_uInt16 POOLGRP_FRAMEFMT = (1 << 11) + POOLGRP_NOCOLLID; ...@@ -78,6 +78,7 @@ const sal_uInt16 POOLGRP_FRAMEFMT = (1 << 11) + POOLGRP_NOCOLLID;
const sal_uInt16 POOLGRP_PAGEDESC = (2 << 11) + POOLGRP_NOCOLLID; const sal_uInt16 POOLGRP_PAGEDESC = (2 << 11) + POOLGRP_NOCOLLID;
const sal_uInt16 POOLGRP_NUMRULE = (3 << 11) + POOLGRP_NOCOLLID; const sal_uInt16 POOLGRP_NUMRULE = (3 << 11) + POOLGRP_NOCOLLID;
const sal_uInt16 POOLGRP_TABSTYLE = (4 << 11) + POOLGRP_NOCOLLID; const sal_uInt16 POOLGRP_TABSTYLE = (4 << 11) + POOLGRP_NOCOLLID;
const sal_uInt16 POOLGRP_CELLSTYLE = (5 << 11) + POOLGRP_NOCOLLID;
/// Recognize whether it's a user defined style or not: /// Recognize whether it's a user defined style or not:
const sal_uInt16 POOL_IDUSER_FMT = const sal_uInt16 POOL_IDUSER_FMT =
...@@ -222,6 +223,12 @@ RES_POOLTABLESTYLE_YELLOW, ...@@ -222,6 +223,12 @@ RES_POOLTABLESTYLE_YELLOW,
RES_POOLTABSTYLE_END RES_POOLTABSTYLE_END
}; };
enum RES_POOL_CELLSTYLE_TYPE
{
RES_POOLCELLSTYLE_BEGIN = POOLGRP_CELLSTYLE,
RES_POOLCELLSTYLE_END = RES_POOLCELLSTYLE_BEGIN
};
// IDs for paragraph styles. // IDs for paragraph styles.
enum RES_POOL_COLLFMT_TYPE enum RES_POOL_COLLFMT_TYPE
{ {
......
...@@ -110,6 +110,8 @@ class SwBoxAutoFormat ...@@ -110,6 +110,8 @@ class SwBoxAutoFormat
OUString m_sNumFormatString; OUString m_sNumFormatString;
LanguageType m_eSysLanguage, m_eNumFormatLanguage; LanguageType m_eSysLanguage, m_eNumFormatLanguage;
css::uno::WeakReference<css::uno::XInterface> m_wXObject;
public: public:
SwBoxAutoFormat(); SwBoxAutoFormat();
SwBoxAutoFormat( const SwBoxAutoFormat& rNew ); SwBoxAutoFormat( const SwBoxAutoFormat& rNew );
...@@ -176,6 +178,11 @@ public: ...@@ -176,6 +178,11 @@ public:
void SetValueFormat( const OUString& rFormat, LanguageType eLng, LanguageType eSys ) void SetValueFormat( const OUString& rFormat, LanguageType eLng, LanguageType eSys )
{ m_sNumFormatString = rFormat; m_eNumFormatLanguage = eLng; m_eSysLanguage = eSys; } { m_sNumFormatString = rFormat; m_eNumFormatLanguage = eLng; m_eSysLanguage = eSys; }
css::uno::WeakReference<css::uno::XInterface> const& GetXObject() const
{ return m_wXObject; }
void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject)
{ m_wXObject = xObject; }
bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer ); bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer );
bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const; bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
bool SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const; bool SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const;
...@@ -300,6 +307,11 @@ public: ...@@ -300,6 +307,11 @@ public:
{ return m_wXObject; } { return m_wXObject; }
void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject) void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject)
{ m_wXObject = xObject; } { m_wXObject = xObject; }
/// Returns the cell's name postfix. eg. ".1"
OUString GetTableTemplateCellSubName(const SwBoxAutoFormat& rBoxFormat) const;
/// Returns a vector of indexes in aBoxAutoFormat array. Returned indexes points to cells which are mapped to a table-template.
static const std::vector<sal_Int32>& GetTableTemplateMap();
}; };
class SW_DLLPUBLIC SwTableAutoFormatTable class SW_DLLPUBLIC SwTableAutoFormatTable
......
...@@ -30,8 +30,9 @@ ...@@ -30,8 +30,9 @@
#define STR_STYLE_FAMILY_PAGE (RC_UNOCORE_BEGIN + 6) #define STR_STYLE_FAMILY_PAGE (RC_UNOCORE_BEGIN + 6)
#define STR_STYLE_FAMILY_NUMBERING (RC_UNOCORE_BEGIN + 7) #define STR_STYLE_FAMILY_NUMBERING (RC_UNOCORE_BEGIN + 7)
#define STR_STYLE_FAMILY_TABLE (RC_UNOCORE_BEGIN + 8) #define STR_STYLE_FAMILY_TABLE (RC_UNOCORE_BEGIN + 8)
#define STR_STYLE_FAMILY_CELL (RC_UNOCORE_BEGIN + 9)
#define UNOCORE_ACT_END STR_STYLE_FAMILY_TABLE #define UNOCORE_ACT_END STR_STYLE_FAMILY_CELL
#if UNOCORE_ACT_END > RC_UNOCORE_END #if UNOCORE_ACT_END > RC_UNOCORE_END
#error Resource-Id Ueberlauf in #file, #line #error Resource-Id Ueberlauf in #file, #line
......
...@@ -312,12 +312,15 @@ class SwBoxAutoFormat; ...@@ -312,12 +312,15 @@ class SwBoxAutoFormat;
class SwXTextCellStyle : public cppu::WeakImplHelper class SwXTextCellStyle : public cppu::WeakImplHelper
< <
css::style::XStyle, css::style::XStyle,
css::beans::XPropertySet css::beans::XPropertySet,
css::lang::XServiceInfo
> >
{ {
SwDocShell* m_pDocShell;
SwBoxAutoFormat& m_rBoxAutoFormat; SwBoxAutoFormat& m_rBoxAutoFormat;
OUString m_sParentStyle;
public: public:
SwXTextCellStyle(SwBoxAutoFormat& rBoxAutoFormat); SwXTextCellStyle(SwDocShell* pDocShell, SwBoxAutoFormat& rBoxAutoFormat, const OUString& sParentStyle);
//XStyle //XStyle
virtual sal_Bool SAL_CALL isUserDefined() throw (css::uno::RuntimeException, std::exception) override; virtual sal_Bool SAL_CALL isUserDefined() throw (css::uno::RuntimeException, std::exception) override;
...@@ -338,6 +341,12 @@ public: ...@@ -338,6 +341,12 @@ public:
virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
//XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw(css::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw(css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
static css::uno::Reference<css::style::XStyle> CreateXTextCellStyle(SwDocShell* pDocShell, const OUString& sName);
}; };
#endif #endif
......
...@@ -39,11 +39,11 @@ class CheckStyle(unittest.TestCase): ...@@ -39,11 +39,11 @@ class CheckStyle(unittest.TestCase):
self.assertFalse(xStyleFamilies.supportsService("foobarbaz")) self.assertFalse(xStyleFamilies.supportsService("foobarbaz"))
self.assertTrue(xStyleFamilies.hasElements()) self.assertTrue(xStyleFamilies.hasElements())
self.assertRegex(str(xStyleFamilies.ElementType), "com\.sun\.star\.container\.XNameContainer") self.assertRegex(str(xStyleFamilies.ElementType), "com\.sun\.star\.container\.XNameContainer")
self.assertEqual(len(xStyleFamilies.ElementNames), 6) self.assertEqual(len(xStyleFamilies.ElementNames), 7)
for sFamilyname in xStyleFamilies.ElementNames: for sFamilyname in xStyleFamilies.ElementNames:
self.assertIn(sFamilyname, self.assertIn(sFamilyname,
["CharacterStyles", "ParagraphStyles", "PageStyles", "FrameStyles", "NumberingStyles", "TableStyles"]) ["CharacterStyles", "ParagraphStyles", "PageStyles", "FrameStyles", "NumberingStyles", "TableStyles", "CellStyles"])
with self.assertRaises(NoSuchElementException): with self.assertRaises(NoSuchElementException):
xStyleFamilies.getByName("foobarbaz") xStyleFamilies.getByName("foobarbaz")
...@@ -183,6 +183,14 @@ class CheckStyle(unittest.TestCase): ...@@ -183,6 +183,14 @@ class CheckStyle(unittest.TestCase):
xCellStyle.getPropertyValue("foobarbaz") xCellStyle.getPropertyValue("foobarbaz")
xDoc.dispose() xDoc.dispose()
def test_CellFamily(self):
xDoc = CheckStyle._uno.openEmptyWriterDoc()
xCellStyles = xDoc.StyleFamilies["CellStyles"]
vEmptyDocStyles = ['Default Style.1', 'Default Style.2', 'Default Style.3', 'Default Style.4', 'Default Style.5', 'Default Style.6', 'Default Style.7', 'Default Style.8', 'Default Style.9', 'Default Style.10']
self.__test_StyleFamily(xCellStyles, vEmptyDocStyles, "SwXTextCellStyle")
#possibly more depth tests could be added, to test properties of a cell style... yet to come
xDoc.dispose()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
......
...@@ -43,6 +43,7 @@ extern ResMgr* pSwResMgr; ...@@ -43,6 +43,7 @@ extern ResMgr* pSwResMgr;
*SwStyleNameMapper::m_pPageDescUINameArray = nullptr, *SwStyleNameMapper::m_pPageDescUINameArray = nullptr,
*SwStyleNameMapper::m_pNumRuleUINameArray = nullptr, *SwStyleNameMapper::m_pNumRuleUINameArray = nullptr,
*SwStyleNameMapper::m_pTableStyleUINameArray = nullptr, *SwStyleNameMapper::m_pTableStyleUINameArray = nullptr,
*SwStyleNameMapper::m_pCellStyleUINameArray = nullptr,
// Initialise programmatic names to 0 // Initialise programmatic names to 0
*SwStyleNameMapper::m_pTextProgNameArray = nullptr, *SwStyleNameMapper::m_pTextProgNameArray = nullptr,
...@@ -56,7 +57,8 @@ extern ResMgr* pSwResMgr; ...@@ -56,7 +57,8 @@ extern ResMgr* pSwResMgr;
*SwStyleNameMapper::m_pHTMLChrFormatProgNameArray = nullptr, *SwStyleNameMapper::m_pHTMLChrFormatProgNameArray = nullptr,
*SwStyleNameMapper::m_pPageDescProgNameArray = nullptr, *SwStyleNameMapper::m_pPageDescProgNameArray = nullptr,
*SwStyleNameMapper::m_pNumRuleProgNameArray = nullptr, *SwStyleNameMapper::m_pNumRuleProgNameArray = nullptr,
*SwStyleNameMapper::m_pTableStyleProgNameArray = nullptr; *SwStyleNameMapper::m_pTableStyleProgNameArray = nullptr,
*SwStyleNameMapper::m_pCellStyleProgNameArray = nullptr;
NameToIdHash *SwStyleNameMapper::m_pParaUIMap = nullptr, NameToIdHash *SwStyleNameMapper::m_pParaUIMap = nullptr,
*SwStyleNameMapper::m_pCharUIMap = nullptr, *SwStyleNameMapper::m_pCharUIMap = nullptr,
...@@ -64,13 +66,15 @@ NameToIdHash *SwStyleNameMapper::m_pParaUIMap = nullptr, ...@@ -64,13 +66,15 @@ NameToIdHash *SwStyleNameMapper::m_pParaUIMap = nullptr,
*SwStyleNameMapper::m_pFrameUIMap = nullptr, *SwStyleNameMapper::m_pFrameUIMap = nullptr,
*SwStyleNameMapper::m_pNumRuleUIMap = nullptr, *SwStyleNameMapper::m_pNumRuleUIMap = nullptr,
*SwStyleNameMapper::m_pTableStyleUIMap = nullptr, *SwStyleNameMapper::m_pTableStyleUIMap = nullptr,
*SwStyleNameMapper::m_pCellStyleUIMap = nullptr,
*SwStyleNameMapper::m_pParaProgMap = nullptr, *SwStyleNameMapper::m_pParaProgMap = nullptr,
*SwStyleNameMapper::m_pCharProgMap = nullptr, *SwStyleNameMapper::m_pCharProgMap = nullptr,
*SwStyleNameMapper::m_pPageProgMap = nullptr, *SwStyleNameMapper::m_pPageProgMap = nullptr,
*SwStyleNameMapper::m_pFrameProgMap = nullptr, *SwStyleNameMapper::m_pFrameProgMap = nullptr,
*SwStyleNameMapper::m_pNumRuleProgMap = nullptr, *SwStyleNameMapper::m_pNumRuleProgMap = nullptr,
*SwStyleNameMapper::m_pTableStyleProgMap = nullptr; *SwStyleNameMapper::m_pTableStyleProgMap = nullptr,
*SwStyleNameMapper::m_pCellStyleProgMap = nullptr;
// SwTableEntry so we can pass the length to the String CTOR // SwTableEntry so we can pass the length to the String CTOR
struct SwTableEntry struct SwTableEntry
...@@ -498,6 +502,12 @@ const NameToIdHash & SwStyleNameMapper::getHashTable ( SwGetPoolIdFromName eFlag ...@@ -498,6 +502,12 @@ const NameToIdHash & SwStyleNameMapper::getHashTable ( SwGetPoolIdFromName eFlag
vIndexes.push_back( std::make_tuple(RES_POOLTABSTYLE_BEGIN, RES_POOLTABSTYLE_END, bProgName ? &GetTableStyleProgNameArray : &GetTableStyleUINameArray) ); vIndexes.push_back( std::make_tuple(RES_POOLTABSTYLE_BEGIN, RES_POOLTABSTYLE_END, bProgName ? &GetTableStyleProgNameArray : &GetTableStyleUINameArray) );
} }
break; break;
case nsSwGetPoolIdFromName::GET_POOLID_CELLSTYLE:
{
pHashPointer = bProgName ? &m_pCellStyleProgMap : &m_pCellStyleUIMap;
vIndexes.push_back( std::make_tuple(RES_POOLCELLSTYLE_BEGIN, RES_POOLCELLSTYLE_END, bProgName ? &GetCellStyleProgNameArray : &GetCellStyleUINameArray) );
}
break;
default: default:
assert(false && "unknown pool family"); assert(false && "unknown pool family");
} }
...@@ -855,6 +865,14 @@ const ::std::vector<OUString>& SwStyleNameMapper::GetTableStyleUINameArray() ...@@ -855,6 +865,14 @@ const ::std::vector<OUString>& SwStyleNameMapper::GetTableStyleUINameArray()
return *m_pTableStyleUINameArray; return *m_pTableStyleUINameArray;
} }
/// retuns an empty array because Cell Names aren't translated
const ::std::vector<OUString>& SwStyleNameMapper::GetCellStyleUINameArray()
{
if (!m_pCellStyleUINameArray)
m_pCellStyleUINameArray = new std::vector<OUString>();
return *m_pCellStyleUINameArray;
}
const ::std::vector<OUString>& SwStyleNameMapper::GetTextProgNameArray() const ::std::vector<OUString>& SwStyleNameMapper::GetTextProgNameArray()
{ {
if (!m_pTextProgNameArray) if (!m_pTextProgNameArray)
...@@ -951,6 +969,14 @@ const ::std::vector<OUString>& SwStyleNameMapper::GetTableStyleProgNameArray() ...@@ -951,6 +969,14 @@ const ::std::vector<OUString>& SwStyleNameMapper::GetTableStyleProgNameArray()
return *m_pTableStyleProgNameArray; return *m_pTableStyleProgNameArray;
} }
/// retuns an empty array because Cell Names aren't translated
const ::std::vector<OUString>& SwStyleNameMapper::GetCellStyleProgNameArray()
{
if (!m_pCellStyleProgNameArray)
m_pCellStyleProgNameArray = new std::vector<OUString>();
return *m_pCellStyleProgNameArray;
}
const OUString const OUString
SwStyleNameMapper::GetSpecialExtraProgName(const OUString& rExtraUIName) SwStyleNameMapper::GetSpecialExtraProgName(const OUString& rExtraUIName)
{ {
......
...@@ -1029,6 +1029,47 @@ bool SwTableAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const ...@@ -1029,6 +1029,47 @@ bool SwTableAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
return bRet; return bRet;
} }
OUString SwTableAutoFormat::GetTableTemplateCellSubName(const SwBoxAutoFormat& rBoxFormat) const
{
sal_Int32 nIndex = 0;
for (; nIndex < 16; ++nIndex)
if (aBoxAutoFormat[nIndex] == &rBoxFormat) break;
// box format doesn't belong to this table format
if (16 <= nIndex)
return OUString();
const std::vector<sal_Int32> aTableTemplateMap = GetTableTemplateMap();
for (size_t i=0; i < aTableTemplateMap.size(); ++i)
{
if (aTableTemplateMap[i] == nIndex)
return "." + OUString::number(i + 1);
}
// box format doesn't belong to a table template
return OUString();
}
const std::vector<sal_Int32>& SwTableAutoFormat::GetTableTemplateMap()
{
static std::vector<sal_Int32>* pTableTemplateMap;
if (!pTableTemplateMap)
{
pTableTemplateMap = new std::vector<sal_Int32>;
pTableTemplateMap->push_back(0); // FIRST_ROW
pTableTemplateMap->push_back(1); // LAST_ROW
pTableTemplateMap->push_back(2); // FIRST_COLUMN
pTableTemplateMap->push_back(3); // LAST_COLUMN
pTableTemplateMap->push_back(4); // EVEN_ROWS
pTableTemplateMap->push_back(5); // ODD_ROWS
pTableTemplateMap->push_back(6); // EVEN_COLUMNS
pTableTemplateMap->push_back(7); // ODD_COLUMNS
pTableTemplateMap->push_back(8); // BODY
pTableTemplateMap->push_back(9); // BACKGROUND
}
return *pTableTemplateMap;
}
struct SwTableAutoFormatTable::Impl struct SwTableAutoFormatTable::Impl
{ {
std::vector<std::unique_ptr<SwTableAutoFormat>> m_AutoFormats; std::vector<std::unique_ptr<SwTableAutoFormat>> m_AutoFormats;
......
...@@ -59,4 +59,9 @@ String STR_STYLE_FAMILY_TABLE ...@@ -59,4 +59,9 @@ String STR_STYLE_FAMILY_TABLE
Text [ en-US ] = "Table" ; Text [ en-US ] = "Table" ;
}; };
String STR_STYLE_FAMILY_CELL
{
Text [ en-US ] = "Cell" ;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#define cPAGE (sal_Unicode)'g' #define cPAGE (sal_Unicode)'g'
#define cNUMRULE (sal_Unicode)'n' #define cNUMRULE (sal_Unicode)'n'
#define cTABSTYLE (sal_Unicode)'t' #define cTABSTYLE (sal_Unicode)'t'
#define cCELLSTYLE (sal_Unicode)'b'
using namespace com::sun::star; using namespace com::sun::star;
...@@ -320,6 +321,40 @@ static const SwTableAutoFormat* lcl_FindTableStyle(SwDoc& rDoc, const OUString& ...@@ -320,6 +321,40 @@ static const SwTableAutoFormat* lcl_FindTableStyle(SwDoc& rDoc, const OUString&
return pFormat; return pFormat;
} }
static const SwBoxAutoFormat* lcl_FindCellStyle(SwDoc& rDoc, const OUString& rName, SwDocStyleSheet *pStyle = nullptr)
{
const SwBoxAutoFormat* pFormat = nullptr;
auto aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
for (size_t i=0; i < rTableStyles.size() && !pFormat; ++i)
{
const SwTableAutoFormat& rTableStyle = rTableStyles[i];
for (size_t nBoxFormat=0; nBoxFormat < aTableTemplateMap.size() && !pFormat; ++nBoxFormat)
{
const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
OUString sBoxFormatName;
SwStyleNameMapper::FillProgName(rTableStyle.GetName(), sBoxFormatName, nsSwGetPoolIdFromName::GET_POOLID_CELLSTYLE, true);
sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
if (rName == sBoxFormatName)
pFormat = &rBoxFormat;
}
}
if(pStyle)
{
if(pFormat)
{
pStyle->SetPhysical(true);
pStyle->PresetParent(OUString());
}
else
pStyle->SetPhysical(false);
}
return pFormat;
}
sal_uInt32 SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily eFam, sal_uInt32 SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily eFam,
const OUString &rName) const OUString &rName)
{ {
...@@ -346,6 +381,9 @@ sal_uInt32 SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily eFam, ...@@ -346,6 +381,9 @@ sal_uInt32 SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily eFam,
case SfxStyleFamily::Table: case SfxStyleFamily::Table:
cStyle = cTABSTYLE; cStyle = cTABSTYLE;
break; break;
case SfxStyleFamily::Cell:
cStyle = cCELLSTYLE;
break;
default: default:
cStyle = ' '; cStyle = ' ';
break; break;
...@@ -1945,6 +1983,11 @@ bool SwDocStyleSheet::FillStyleSheet( ...@@ -1945,6 +1983,11 @@ bool SwDocStyleSheet::FillStyleSheet(
pTableFormat = lcl_FindTableStyle(rDoc, aName, this); pTableFormat = lcl_FindTableStyle(rDoc, aName, this);
bRet = bPhysical = (nullptr != pTableFormat); bRet = bPhysical = (nullptr != pTableFormat);
break; break;
case SfxStyleFamily::Cell:
pBoxFormat = lcl_FindCellStyle(rDoc, aName, this);
bRet = bPhysical = (nullptr != pBoxFormat);
break;
default:; //prevent warning default:; //prevent warning
} }
...@@ -2529,6 +2572,9 @@ SfxStyleSheetBase* SwDocStyleSheetPool::Find( const OUString& rName, ...@@ -2529,6 +2572,9 @@ SfxStyleSheetBase* SwDocStyleSheetPool::Find( const OUString& rName,
} }
break; break;
case SfxStyleFamily::Table:
case SfxStyleFamily::Cell:
break;
default: default:
OSL_ENSURE(false, "unknown style family"); OSL_ENSURE(false, "unknown style family");
} }
...@@ -2941,6 +2987,26 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() ...@@ -2941,6 +2987,26 @@ SfxStyleSheetBase* SwStyleSheetIterator::First()
} }
} }
if( nSearchFamily == SfxStyleFamily::Cell ||
nSearchFamily == SfxStyleFamily::All )
{
const std::vector<sal_Int32> aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
for(size_t i = 0; i < rTableStyles.size(); ++i)
{
const SwTableAutoFormat& rTableStyle = rTableStyles[i];
for(size_t nBoxFormat = 0; nBoxFormat < aTableTemplateMap.size(); ++nBoxFormat)
{
const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
OUString sBoxFormatName;
SwStyleNameMapper::FillProgName(rTableStyle.GetName(), sBoxFormatName, nsSwGetPoolIdFromName::GET_POOLID_CELLSTYLE, true);
sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
aLst.Append( cCELLSTYLE, sBoxFormatName );
}
}
}
if(!aLst.empty()) if(!aLst.empty())
{ {
nLastPos = SAL_MAX_UINT32; nLastPos = SAL_MAX_UINT32;
......
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