diff options
author | Jeff Huang <jeff@mail.ossii.com.tw> | 2021-07-19 17:00:17 +0800 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2021-07-23 13:29:22 +0200 |
commit | 2c0b84dc65739bfc47dca684e819717eb9cce387 (patch) | |
tree | ebcc1fc045f9deea2ec0890e5dbac342b1f74934 /sfx2 | |
parent | badc5a7ac8dda3c7b991c671776d2d41a5b7ea26 (diff) |
tdf#140107 Remove all collect usage data code.
Remove all collect usage data code because we
don't really use them.
Change-Id: I8d83d57220bed8f8c15bd012584943cd0913500d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119166
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index cf6985ecedda..1eb2726f212a 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -504,147 +504,6 @@ OUString SfxDispatchController_Impl::getSlaveCommand( const css::util::URL& rURL namespace { -/// Class that collects the usage information - how many times what .uno: command was used. -class UsageInfo { - - typedef std::map<OUString, int> UsageMap; - - /// Are we collecting the info? We cache the value because the call to save can happen very late. - bool mbIsCollecting; - - /// Command vs. how many times it was used - UsageMap maUsage; - - /// config path, get it long before atexit time - OUString msConfigPath; - -public: - UsageInfo() : mbIsCollecting(false) - { - } - - ~UsageInfo() - { - save(); - } - - /// Increment command's use. - void increment(const OUString &rCommand); - - /// Save the usage data for the next session. - void save(); - - /// Modify the flag whether we are collecting. - void setCollecting(bool bIsCollecting) - { - mbIsCollecting = bIsCollecting; - if (mbIsCollecting) - { - msConfigPath = SvtPathOptions().GetConfigPath(); - msConfigPath += "usage/"; - } - } -}; - -void UsageInfo::increment(const OUString &rCommand) -{ - UsageMap::iterator it = maUsage.find(rCommand); - - if (it != maUsage.end()) - ++(it->second); - else - maUsage[rCommand] = 1; -} - -void UsageInfo::save() -{ - if (!mbIsCollecting) - return; - - osl::Directory::createPath(msConfigPath); - - //get system time information. - TimeValue systemTime; - TimeValue localTime; - oslDateTime localDateTime; - osl_getSystemTime( &systemTime ); - osl_getLocalTimeFromSystemTime( &systemTime, &localTime ); - osl_getDateTimeFromTimeValue( &localTime, &localDateTime ); - - char time[1024]; - sprintf(time,"%4i-%02i-%02iT%02i_%02i_%02i", localDateTime.Year, localDateTime.Month, localDateTime.Day, localDateTime.Hours, localDateTime.Minutes, localDateTime.Seconds); - - //filename type: usage-YYYY-MM-DDTHH_MM_SS.csv - OUString filename = "usage-" + OUString::createFromAscii(time) + ".csv"; - OUString path = msConfigPath + filename; - - osl::File file(path); - - if( file.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create) == osl::File::E_None ) - { - OStringBuffer aUsageInfoMsg("Document Type;Command;Count"); - - for (auto const& elem : maUsage) - aUsageInfoMsg.append("\n" + elem.first.toUtf8() + ";" + OString::number(elem.second)); - - sal_uInt64 written = 0; - auto s = aUsageInfoMsg.makeStringAndClear(); - file.write(s.getStr(), s.getLength(), written); - file.close(); - } -} - -class theUsageInfo : public rtl::Static<UsageInfo, theUsageInfo> {}; - -/// Extracts information about the command + args, and stores that. -void collectUsageInformation(const util::URL& rURL, const uno::Sequence<beans::PropertyValue>& rArgs) -{ - bool bCollecting = getenv("LO_COLLECT_USAGE") || officecfg::Office::Common::Misc::CollectUsageInformation::get(); - theUsageInfo::get().setCollecting(bCollecting); - if (!bCollecting) - return; - - OUStringBuffer aBuffer; - - // app identification [uh, several UNO calls :-(] - uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - uno::Reference<frame::XModuleManager2> xModuleManager(frame::ModuleManager::create(xContext)); - uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext); - uno::Reference<frame::XFrame> xFrame = xDesktop->getCurrentFrame(); - - OUString aModule(xModuleManager->identify(xFrame)); - sal_Int32 nLastDot = aModule.lastIndexOf('.'); - if (nLastDot >= 0) - aModule = aModule.copy(nLastDot + 1); - - aBuffer.append(aModule); - aBuffer.append(';'); - - // command - aBuffer.append(rURL.Protocol); - aBuffer.append(rURL.Path); - sal_Int32 nCount = rArgs.getLength(); - - // parameters - only their names, not the values (could be sensitive!) - if (nCount > 0) - { - aBuffer.append('('); - for (sal_Int32 n = 0; n < nCount; n++) - { - const css::beans::PropertyValue& rProp = rArgs[n]; - if (n > 0) - aBuffer.append(','); - aBuffer.append(rProp.Name); - } - aBuffer.append(')'); - } - - OUString aCommand(aBuffer.makeStringAndClear()); - - // store - theUsageInfo::get().increment(aCommand); -} - void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs) { static const char* pFile = std::getenv("LO_COLLECT_UIINFO"); @@ -664,7 +523,6 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, { CrashReporter::logUnoCommand(aURL.Path); } - collectUsageInformation(aURL, aArgs); collectUIInformation(aURL, aArgs); SolarMutexGuard aGuard; |