diff options
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/unoobj/fmtuno.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/unoobj/styleuno.cxx | 143 |
3 files changed, 3 insertions, 142 deletions
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 93192ae4083a..763bf67051cf 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -121,6 +121,7 @@ #include "stringutil.hxx" #include "formulaiter.hxx" #include "tokenarray.hxx" +#include "stylehelper.hxx" #include <list> #include <boost/scoped_ptr.hpp> diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 197321325c2c..67a2ad82323f 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -35,6 +35,7 @@ #include "styleuno.hxx" // ScStyleNameConversion #include "tokenarray.hxx" #include "tokenuno.hxx" +#include "stylehelper.hxx" using namespace ::com::sun::star; using namespace ::formula; diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 9c7cc587d386..246639d0c609 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -63,6 +63,7 @@ #include "unowids.hxx" #include "globstr.hrc" #include "cellsuno.hxx" +#include "stylehelper.hxx" using namespace ::com::sun::star; @@ -397,148 +398,6 @@ SC_SIMPLE_SERVICE_INFO( ScStyleFamilyObj, "ScStyleFamilyObj", "com.sun.star.styl //------------------------------------------------------------------------ -// conversion programmatic <-> display (visible) name -// currently, the core always has the visible names -// the api is required to use programmatic names for default styles -// these programmatic names must never change! - -#define SC_STYLE_PROG_STANDARD "Default" -#define SC_STYLE_PROG_RESULT "Result" -#define SC_STYLE_PROG_RESULT1 "Result2" -#define SC_STYLE_PROG_HEADLINE "Heading" -#define SC_STYLE_PROG_HEADLINE1 "Heading1" -#define SC_STYLE_PROG_REPORT "Report" - -struct ScDisplayNameMap -{ - String aDispName; - String aProgName; -}; - -static const ScDisplayNameMap* lcl_GetStyleNameMap( sal_uInt16 nType ) -{ - if ( nType == SFX_STYLE_FAMILY_PARA ) - { - static sal_Bool bCellMapFilled = false; - static ScDisplayNameMap aCellMap[6]; - if ( !bCellMapFilled ) - { - aCellMap[0].aDispName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD ); - aCellMap[0].aProgName = OUString( SC_STYLE_PROG_STANDARD ); - - aCellMap[1].aDispName = ScGlobal::GetRscString( STR_STYLENAME_RESULT ); - aCellMap[1].aProgName = OUString( SC_STYLE_PROG_RESULT ); - - aCellMap[2].aDispName = ScGlobal::GetRscString( STR_STYLENAME_RESULT1 ); - aCellMap[2].aProgName = OUString( SC_STYLE_PROG_RESULT1 ); - - aCellMap[3].aDispName = ScGlobal::GetRscString( STR_STYLENAME_HEADLINE ); - aCellMap[3].aProgName = OUString( SC_STYLE_PROG_HEADLINE ); - - aCellMap[4].aDispName = ScGlobal::GetRscString( STR_STYLENAME_HEADLINE1 ); - aCellMap[4].aProgName = OUString( SC_STYLE_PROG_HEADLINE1 ); - - // last entry remains empty - - bCellMapFilled = sal_True; - } - return aCellMap; - } - else if ( nType == SFX_STYLE_FAMILY_PAGE ) - { - static sal_Bool bPageMapFilled = false; - static ScDisplayNameMap aPageMap[3]; - if ( !bPageMapFilled ) - { - aPageMap[0].aDispName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD ); - aPageMap[0].aProgName = OUString( SC_STYLE_PROG_STANDARD ); - - aPageMap[1].aDispName = ScGlobal::GetRscString( STR_STYLENAME_REPORT ); - aPageMap[1].aProgName = OUString( SC_STYLE_PROG_REPORT ); - - // last entry remains empty - - bPageMapFilled = sal_True; - } - return aPageMap; - } - OSL_FAIL("invalid family"); - return NULL; -} - -// programmatic name suffix for display names that match other programmatic names -// is " (user)" including a space - -#define SC_SUFFIX_USER " (user)" -#define SC_SUFFIX_USER_LEN 7 - -static sal_Bool lcl_EndsWithUser( const String& rString ) -{ - const sal_Unicode *pChar = rString.GetBuffer(); - xub_StrLen nLen = rString.Len(); - return nLen >= SC_SUFFIX_USER_LEN && - pChar[nLen-7] == ' ' && - pChar[nLen-6] == '(' && - pChar[nLen-5] == 'u' && - pChar[nLen-4] == 's' && - pChar[nLen-3] == 'e' && - pChar[nLen-2] == 'r' && - pChar[nLen-1] == ')'; -} - -String ScStyleNameConversion::DisplayToProgrammaticName( const String& rDispName, sal_uInt16 nType ) -{ - sal_Bool bDisplayIsProgrammatic = false; - - const ScDisplayNameMap* pNames = lcl_GetStyleNameMap( nType ); - if (pNames) - { - do - { - if (pNames->aDispName == rDispName) - return pNames->aProgName; - else if (pNames->aProgName == rDispName) - bDisplayIsProgrammatic = sal_True; // display name matches any programmatic name - } - while( (++pNames)->aDispName.Len() ); - } - - if ( bDisplayIsProgrammatic || lcl_EndsWithUser( rDispName ) ) - { - // add the (user) suffix if the display name matches any style's programmatic name - // or if it already contains the suffix - - String aRet(rDispName); - aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SC_SUFFIX_USER ) ); - return aRet; - } - - return rDispName; -} - -String ScStyleNameConversion::ProgrammaticToDisplayName( const String& rProgName, sal_uInt16 nType ) -{ - if ( lcl_EndsWithUser( rProgName ) ) - { - // remove the (user) suffix, don't compare to map entries - return rProgName.Copy( 0, rProgName.Len() - SC_SUFFIX_USER_LEN ); - } - - const ScDisplayNameMap* pNames = lcl_GetStyleNameMap( nType ); - if (pNames) - { - do - { - if (pNames->aProgName == rProgName) - return pNames->aDispName; - } - while( (++pNames)->aDispName.Len() ); - } - return rProgName; -} - -//------------------------------------------------------------------------ - static sal_Bool lcl_AnyTabProtected( ScDocument& rDoc ) { SCTAB nTabCount = rDoc.GetTableCount(); |