diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-03-31 23:43:57 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-04-02 14:53:48 +0100 |
commit | 15f14ec79477142cf2bcb1484511b7bea6f1485b (patch) | |
tree | f8286d0e17062b579289a43fe3aa01ddb421d6d2 | |
parent | ae9219769106648ac35d594fc07c83103a62ecbe (diff) |
reorganize trickier statics
-rw-r--r-- | basic/source/uno/dlgcont.cxx | 22 | ||||
-rw-r--r-- | desktop/source/deployment/misc/dp_resource.cxx | 6 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 71 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.hxx | 10 | ||||
-rw-r--r-- | sw/source/core/crsr/bookmrk.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/crsr/crossrefbookmark.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/inc/bookmrk.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/inc/crossrefbookmark.hxx | 2 | ||||
-rw-r--r-- | ucbhelper/source/client/contentbroker.cxx | 9 |
9 files changed, 76 insertions, 84 deletions
diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx index fa99fe165b98..4c4c502cc82b 100644 --- a/basic/source/uno/dlgcont.cxx +++ b/basic/source/uno/dlgcont.cxx @@ -400,9 +400,8 @@ SfxLibraryContainer* SfxDialogLibraryContainer::createInstanceImpl( void ) return new SfxDialogLibraryContainer(); } - -static OUString aResourceFileNameBase(RTL_CONSTASCII_USTRINGPARAM("DialogStrings")); -static OUString aResourceFileCommentBase(RTL_CONSTASCII_USTRINGPARAM("# Strings for Dialog Library ")); +const char aResourceFileNameBase[] = "DialogStrings"; +const char aResourceFileCommentBase[] = "# Strings for Dialog Library "; // Resource handling Reference< ::com::sun::star::resource::XStringResourcePersistence > @@ -415,7 +414,7 @@ Reference< ::com::sun::star::resource::XStringResourcePersistence > // get ui locale ::com::sun ::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); - OUString aComment = aResourceFileCommentBase; + OUString aComment(aResourceFileCommentBase); aComment += aLibName; sal_Bool bStorage = mxStorage.is(); @@ -424,7 +423,7 @@ Reference< ::com::sun::star::resource::XStringResourcePersistence > Sequence<Any> aArgs( 5 ); aArgs[1] <<= bReadOnly; aArgs[2] <<= aLocale; - aArgs[3] <<= aResourceFileNameBase; + aArgs[3] <<= rtl::OUString(aResourceFileNameBase); aArgs[4] <<= aComment; // TODO: Ctor @@ -468,7 +467,7 @@ Reference< ::com::sun::star::resource::XStringResourcePersistence > aArgs[0] <<= aLocation; aArgs[1] <<= bReadOnly; aArgs[2] <<= aLocale; - aArgs[3] <<= aResourceFileNameBase; + aArgs[3] <<= rtl::OUString(aResourceFileNameBase); aArgs[4] <<= aComment; // TODO: Real handler? @@ -632,7 +631,7 @@ void SfxDialogLibrary::storeResources( void ) void SfxDialogLibrary::storeResourcesAsURL ( const ::rtl::OUString& URL, const ::rtl::OUString& NewName ) { - OUString aComment = aResourceFileCommentBase; + OUString aComment(aResourceFileCommentBase); m_aName = NewName; aComment += m_aName; @@ -650,26 +649,26 @@ void SfxDialogLibrary::storeResourcesAsURL void SfxDialogLibrary::storeResourcesToURL( const OUString& URL, const Reference< task::XInteractionHandler >& xHandler ) { - OUString aComment = aResourceFileCommentBase; + OUString aComment(aResourceFileCommentBase); aComment += m_aName; if( m_xStringResourcePersistence.is() ) { m_xStringResourcePersistence->storeToURL - ( URL, aResourceFileNameBase, aComment, xHandler ); + ( URL, rtl::OUString(aResourceFileNameBase), aComment, xHandler ); } } void SfxDialogLibrary::storeResourcesToStorage( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XStorage >& xStorage ) { - OUString aComment = aResourceFileCommentBase; + OUString aComment(aResourceFileCommentBase); aComment += m_aName; if( m_xStringResourcePersistence.is() ) { m_xStringResourcePersistence->storeToStorage - ( xStorage, aResourceFileNameBase, aComment ); + ( xStorage, rtl::OUString(aResourceFileNameBase), aComment ); } } @@ -698,6 +697,5 @@ bool SAL_CALL SfxDialogLibrary::isLibraryElementValid( ::com::sun::star::uno::An } } -//============================================================================ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/misc/dp_resource.cxx b/desktop/source/deployment/misc/dp_resource.cxx index 4999e7870d4c..cb594f0aee99 100644 --- a/desktop/source/deployment/misc/dp_resource.cxx +++ b/desktop/source/deployment/misc/dp_resource.cxx @@ -63,21 +63,21 @@ struct DeploymentResMgr : public rtl::StaticWithInit< } }; -osl::Mutex s_mutex; +class theResourceMutex : public rtl::Static<osl::Mutex, theResourceMutex> {}; } // anon namespace //============================================================================== ResId getResId( sal_uInt16 id ) { - const osl::MutexGuard guard( s_mutex ); + const osl::MutexGuard guard( theResourceMutex::get() ); return ResId( id, *DeploymentResMgr::get() ); } //============================================================================== String getResourceString( sal_uInt16 id ) { - const osl::MutexGuard guard( s_mutex ); + const osl::MutexGuard guard( theResourceMutex::get() ); String ret( ResId( id, *DeploymentResMgr::get() ) ); ret.SearchAndReplaceAllAscii( "%PRODUCTNAME", utl::ConfigManager::getProductName() ); diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 67db04b1268e..e3d7e91e23c3 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -28,7 +28,6 @@ #include "fastserializer.hxx" #include <rtl/ustrbuf.hxx> -#include <rtl/byteseq.hxx> #include <comphelper/sequenceasvector.hxx> @@ -62,28 +61,32 @@ using ::com::sun::star::io::NotConnectedException; using ::com::sun::star::io::IOException; using ::com::sun::star::io::BufferSizeExceededException; -static rtl::ByteSequence aClosingBracket((const sal_Int8 *)">", 1); -static rtl::ByteSequence aSlashAndClosingBracket((const sal_Int8 *)"/>", 2); -static rtl::ByteSequence aColon((const sal_Int8 *)":", 1); -static rtl::ByteSequence aOpeningBracket((const sal_Int8 *)"<", 1); -static rtl::ByteSequence aOpeningBracketAndSlash((const sal_Int8 *)"</", 2); -static rtl::ByteSequence aQuote((const sal_Int8 *)"\"", 1); -static rtl::ByteSequence aEqualSignAndQuote((const sal_Int8 *)"=\"", 2); -static rtl::ByteSequence aSpace((const sal_Int8 *)" ", 1); -static rtl::ByteSequence aXmlHeader((const sal_Int8*) "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", 56); - #define HAS_NAMESPACE(x) ((x & 0xffff0000) != 0) #define NAMESPACE(x) (x >> 16) #define TOKEN(x) (x & 0xffff) namespace sax_fastparser { - FastSaxSerializer::FastSaxSerializer( ) : mxOutputStream(), mxFastTokenHandler(), maMarkStack() {} + FastSaxSerializer::FastSaxSerializer( ) + : mxOutputStream() + , mxFastTokenHandler() + , maMarkStack() + , maClosingBracket((const sal_Int8 *)">", 1) + , maSlashAndClosingBracket((const sal_Int8 *)"/>", 2) + , maColon((const sal_Int8 *)":", 1) + , maOpeningBracket((const sal_Int8 *)"<", 1) + , maOpeningBracketAndSlash((const sal_Int8 *)"</", 2) + , maQuote((const sal_Int8 *)"\"", 1) + , maEqualSignAndQuote((const sal_Int8 *)"=\"", 2) + , maSpace((const sal_Int8 *)" ", 1) + { + } FastSaxSerializer::~FastSaxSerializer() {} void SAL_CALL FastSaxSerializer::startDocument( ) throw (SAXException, RuntimeException) { if (!mxOutputStream.is()) return; + rtl::ByteSequence aXmlHeader((const sal_Int8*) "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", 56); writeBytes(toUnoSequence(aXmlHeader)); } @@ -126,7 +129,7 @@ namespace sax_fastparser { { if( HAS_NAMESPACE( nElement ) ) { writeBytes(mxFastTokenHandler->getUTF8Identifier(NAMESPACE(nElement))); - writeBytes(toUnoSequence(aColon)); + writeBytes(toUnoSequence(maColon)); writeBytes(mxFastTokenHandler->getUTF8Identifier(TOKEN(nElement))); } else writeBytes(mxFastTokenHandler->getUTF8Identifier(nElement)); @@ -141,12 +144,12 @@ namespace sax_fastparser { if ( !maMarkStack.empty() ) maMarkStack.top()->setCurrentElement( Element ); - writeBytes(toUnoSequence(aOpeningBracket)); + writeBytes(toUnoSequence(maOpeningBracket)); writeId(Element); writeFastAttributeList(Attribs); - writeBytes(toUnoSequence(aClosingBracket)); + writeBytes(toUnoSequence(maClosingBracket)); } void SAL_CALL FastSaxSerializer::startUnknownElement( const OUString& Namespace, const OUString& Name, const Reference< XFastAttributeList >& Attribs ) @@ -155,19 +158,19 @@ namespace sax_fastparser { if (!mxOutputStream.is()) return; - writeBytes(toUnoSequence(aOpeningBracket)); + writeBytes(toUnoSequence(maOpeningBracket)); if (!Namespace.isEmpty()) { write(Namespace); - writeBytes(toUnoSequence(aColon)); + writeBytes(toUnoSequence(maColon)); } write(Name); writeFastAttributeList(Attribs); - writeBytes(toUnoSequence(aClosingBracket)); + writeBytes(toUnoSequence(maClosingBracket)); } void SAL_CALL FastSaxSerializer::endFastElement( ::sal_Int32 Element ) @@ -176,11 +179,11 @@ namespace sax_fastparser { if (!mxOutputStream.is()) return; - writeBytes(toUnoSequence(aOpeningBracketAndSlash)); + writeBytes(toUnoSequence(maOpeningBracketAndSlash)); writeId(Element); - writeBytes(toUnoSequence(aClosingBracket)); + writeBytes(toUnoSequence(maClosingBracket)); } void SAL_CALL FastSaxSerializer::endUnknownElement( const OUString& Namespace, const OUString& Name ) @@ -189,17 +192,17 @@ namespace sax_fastparser { if (!mxOutputStream.is()) return; - writeBytes(toUnoSequence(aOpeningBracketAndSlash)); + writeBytes(toUnoSequence(maOpeningBracketAndSlash)); if (!Namespace.isEmpty()) { write(Namespace); - writeBytes(toUnoSequence(aColon)); + writeBytes(toUnoSequence(maColon)); } write(Name); - writeBytes(toUnoSequence(aClosingBracket)); + writeBytes(toUnoSequence(maClosingBracket)); } void SAL_CALL FastSaxSerializer::singleFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs ) @@ -211,12 +214,12 @@ namespace sax_fastparser { if ( !maMarkStack.empty() ) maMarkStack.top()->setCurrentElement( Element ); - writeBytes(toUnoSequence(aOpeningBracket)); + writeBytes(toUnoSequence(maOpeningBracket)); writeId(Element); writeFastAttributeList(Attribs); - writeBytes(toUnoSequence(aSlashAndClosingBracket)); + writeBytes(toUnoSequence(maSlashAndClosingBracket)); } void SAL_CALL FastSaxSerializer::singleUnknownElement( const OUString& Namespace, const OUString& Name, const Reference< XFastAttributeList >& Attribs ) @@ -225,19 +228,19 @@ namespace sax_fastparser { if (!mxOutputStream.is()) return; - writeBytes(toUnoSequence(aOpeningBracket)); + writeBytes(toUnoSequence(maOpeningBracket)); if (!Namespace.isEmpty()) { write(Namespace); - writeBytes(toUnoSequence(aColon)); + writeBytes(toUnoSequence(maColon)); } write(Name); writeFastAttributeList(Attribs); - writeBytes(toUnoSequence(aSlashAndClosingBracket)); + writeBytes(toUnoSequence(maSlashAndClosingBracket)); } void SAL_CALL FastSaxSerializer::characters( const OUString& aChars ) @@ -267,12 +270,12 @@ namespace sax_fastparser { sal_Int32 nAttrLength = aAttrSeq.getLength(); for (sal_Int32 i = 0; i < nAttrLength; i++) { - writeBytes(toUnoSequence(aSpace)); + writeBytes(toUnoSequence(maSpace)); write(pAttr[i].Name); - writeBytes(toUnoSequence(aEqualSignAndQuote)); + writeBytes(toUnoSequence(maEqualSignAndQuote)); write(escapeXml(pAttr[i].Value)); - writeBytes(toUnoSequence(aQuote)); + writeBytes(toUnoSequence(maQuote)); } Sequence< FastAttribute > aFastAttrSeq = Attribs->getFastAttributes(); @@ -280,16 +283,16 @@ namespace sax_fastparser { sal_Int32 nFastAttrLength = aFastAttrSeq.getLength(); for (sal_Int32 j = 0; j < nFastAttrLength; j++) { - writeBytes(toUnoSequence(aSpace)); + writeBytes(toUnoSequence(maSpace)); sal_Int32 nToken = pFastAttr[j].Token; writeId(nToken); - writeBytes(toUnoSequence(aEqualSignAndQuote)); + writeBytes(toUnoSequence(maEqualSignAndQuote)); write(escapeXml(Attribs->getValue(pFastAttr[j].Token))); - writeBytes(toUnoSequence(aQuote)); + writeBytes(toUnoSequence(maQuote)); } } diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx index 57126cbf8585..0b0730d895ed 100644 --- a/sax/source/tools/fastserializer.hxx +++ b/sax/source/tools/fastserializer.hxx @@ -34,6 +34,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <cppuhelper/implbase2.hxx> +#include <rtl/byteseq.hxx> #include <stack> #include <map> @@ -188,6 +189,15 @@ private: void write( const ::rtl::OUString& s ); protected: + rtl::ByteSequence maClosingBracket; + rtl::ByteSequence maSlashAndClosingBracket; + rtl::ByteSequence maColon; + rtl::ByteSequence maOpeningBracket; + rtl::ByteSequence maOpeningBracketAndSlash; + rtl::ByteSequence maQuote; + rtl::ByteSequence maEqualSignAndQuote; + rtl::ByteSequence maSpace; + /** Forward the call to the output stream, or write to the stack. The latter in the case that we are inside a mark(). diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 5087c9cd7b75..bd5c50fc89a2 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -177,21 +177,16 @@ namespace sw { namespace mark } } - NavigatorReminder::NavigatorReminder(const SwPaM& rPaM) - : MarkBase(rPaM, our_sNamePrefix) + : MarkBase(rPaM, rtl::OUString("__NavigatorReminder__")) //<-- everything else uses MarkBase::GenerateNewName ? { } - const ::rtl::OUString NavigatorReminder::our_sNamePrefix(RTL_CONSTASCII_USTRINGPARAM("__NavigatorReminder__")); - UnoMark::UnoMark(const SwPaM& aPaM) - : MarkBase(aPaM, MarkBase::GenerateNewName(our_sNamePrefix)) + : MarkBase(aPaM, MarkBase::GenerateNewName(rtl::OUString("__UnoMark__"))) { } - const ::rtl::OUString UnoMark::our_sNamePrefix(RTL_CONSTASCII_USTRINGPARAM("__UnoMark__")); - DdeBookmark::DdeBookmark(const SwPaM& aPaM) - : MarkBase(aPaM, MarkBase::GenerateNewName(our_sNamePrefix)) + : MarkBase(aPaM, MarkBase::GenerateNewName(rtl::OUString("__DdeLink__"))) , m_aRefObj(NULL) { } @@ -200,8 +195,6 @@ namespace sw { namespace mark m_aRefObj = pObj; } - const ::rtl::OUString DdeBookmark::our_sNamePrefix(RTL_CONSTASCII_USTRINGPARAM("__DdeLink__")); - void DdeBookmark::DeregisterFromDoc(SwDoc* const pDoc) { if(m_aRefObj.Is()) @@ -282,7 +275,7 @@ namespace sw { namespace mark Fieldmark::Fieldmark(const SwPaM& rPaM) - : MarkBase(rPaM, MarkBase::GenerateNewName(our_sNamePrefix)) + : MarkBase(rPaM, MarkBase::GenerateNewName(rtl::OUString("__Fieldmark__"))) { if(!IsExpanded()) SetOtherMarkPos(GetMarkPos()); @@ -315,8 +308,6 @@ namespace sw { namespace mark aPaM.InvalidatePaM(); } - const ::rtl::OUString Fieldmark::our_sNamePrefix(RTL_CONSTASCII_USTRINGPARAM("__Fieldmark__")); - TextFieldmark::TextFieldmark(const SwPaM& rPaM) : Fieldmark(rPaM) { } diff --git a/sw/source/core/crsr/crossrefbookmark.cxx b/sw/source/core/crsr/crossrefbookmark.cxx index 9f77b6c2c9cd..67e0dcb66ee3 100644 --- a/sw/source/core/crsr/crossrefbookmark.cxx +++ b/sw/source/core/crsr/crossrefbookmark.cxx @@ -70,32 +70,32 @@ namespace sw { namespace mark return *static_cast<SwPosition*>(NULL); } + const char CrossRefHeadingBookmark_NamePrefix[] = "__RefHeading__"; + CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM& rPaM, const KeyCode& rCode, const OUString& rName, const OUString& rShortName) - : CrossRefBookmark(rPaM, rCode, rName, rShortName, our_sNamePrefix) + : CrossRefBookmark(rPaM, rCode, rName, rShortName, rtl::OUString(CrossRefHeadingBookmark_NamePrefix)) { } - const ::rtl::OUString CrossRefHeadingBookmark::our_sNamePrefix(RTL_CONSTASCII_USTRINGPARAM("__RefHeading__")); - bool CrossRefHeadingBookmark::IsLegalName(const ::rtl::OUString& rName) { - return rName.match(our_sNamePrefix); + return rName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(CrossRefHeadingBookmark_NamePrefix)); } + const char CrossRefNumItemBookmark_NamePrefix[] = "__RefNumPara__"; + CrossRefNumItemBookmark::CrossRefNumItemBookmark(const SwPaM& rPaM, const KeyCode& rCode, const OUString& rName, const OUString& rShortName) - : CrossRefBookmark(rPaM, rCode, rName, rShortName, our_sNamePrefix) + : CrossRefBookmark(rPaM, rCode, rName, rShortName, rtl::OUString(CrossRefNumItemBookmark_NamePrefix)) { } - const ::rtl::OUString CrossRefNumItemBookmark::our_sNamePrefix(RTL_CONSTASCII_USTRINGPARAM("__RefNumPara__")); - bool CrossRefNumItemBookmark::IsLegalName(const ::rtl::OUString& rName) { - return rName.match(our_sNamePrefix); + return rName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(CrossRefNumItemBookmark_NamePrefix)); } }} diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index 06933e804888..b62c84ccac52 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -132,8 +132,6 @@ namespace sw { namespace mark { public: NavigatorReminder(const SwPaM& rPaM); - private: - static const ::rtl::OUString our_sNamePrefix; }; class UnoMark @@ -141,8 +139,6 @@ namespace sw { namespace mark { public: UnoMark(const SwPaM& rPaM); - private: - static const ::rtl::OUString our_sNamePrefix; }; class DdeBookmark @@ -167,7 +163,6 @@ namespace sw { namespace mark virtual ~DdeBookmark(); private: SwServerObjectRef m_aRefObj; - static const ::rtl::OUString our_sNamePrefix; }; class Bookmark @@ -235,8 +230,6 @@ namespace sw { namespace mark ::rtl::OUString m_aFieldname; ::rtl::OUString m_aFieldHelptext; IFieldmark::parameter_map_t m_vParams; - - static const ::rtl::OUString our_sNamePrefix; }; class TextFieldmark diff --git a/sw/source/core/inc/crossrefbookmark.hxx b/sw/source/core/inc/crossrefbookmark.hxx index ef5f8933a81a..59227e8b7e66 100644 --- a/sw/source/core/inc/crossrefbookmark.hxx +++ b/sw/source/core/inc/crossrefbookmark.hxx @@ -80,7 +80,6 @@ namespace sw { namespace mark const ::rtl::OUString& rShortName); static ::rtl::OUString GenerateNewName(); static bool IsLegalName(const ::rtl::OUString& rName); - static const ::rtl::OUString our_sNamePrefix; }; class CrossRefNumItemBookmark @@ -93,7 +92,6 @@ namespace sw { namespace mark const ::rtl::OUString& rShortName); static ::rtl::OUString GenerateNewName(); static bool IsLegalName(const ::rtl::OUString& rName); - static const ::rtl::OUString our_sNamePrefix; }; }} diff --git a/ucbhelper/source/client/contentbroker.cxx b/ucbhelper/source/client/contentbroker.cxx index d1eb179b5b78..3d217f8fe206 100644 --- a/ucbhelper/source/client/contentbroker.cxx +++ b/ucbhelper/source/client/contentbroker.cxx @@ -34,6 +34,7 @@ *************************************************************************/ #include <osl/diagnose.h> #include <osl/mutex.hxx> +#include <rtl/instance.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/ucb/XContentIdentifierFactory.hpp> @@ -56,9 +57,7 @@ using ::rtl::OUString; namespace { - osl::Mutex globalContentBrokerMutex; - osl::Mutex & getGlobalContentBrokerMutex() { return globalContentBrokerMutex; } - + struct theContentBrokerMutex : public rtl::Static< osl::Mutex, theContentBrokerMutex > {}; } // namespace namespace ucbhelper @@ -184,7 +183,7 @@ sal_Bool ContentBroker::initialize( if ( !m_pTheBroker ) { - osl::Guard< osl::Mutex > aGuard( getGlobalContentBrokerMutex() ); + osl::Guard< osl::Mutex > aGuard( theContentBrokerMutex::get() ); if ( !m_pTheBroker ) { @@ -237,7 +236,7 @@ InitUCBHelper() // static void ContentBroker::deinitialize() { - osl::MutexGuard aGuard( getGlobalContentBrokerMutex() ); + osl::MutexGuard aGuard( theContentBrokerMutex::get() ); delete m_pTheBroker; m_pTheBroker = 0; |