/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
namespace {
FILE* fopen_impl(const fs::path& rPath, constchar* szMode)
{ #ifdef _WIN32 //We need _wfopen to support long file paths on Windows XP return _wfopen(rPath.native_file_string_w().c_str(), o3tl::toW(OUString::createFromAscii(szMode).getStr())); #else return fopen(rPath.native_file_string().c_str(), szMode); #endif
}
}
std::string mod = module;
std::transform (mod.begin(), mod.end(), mod.begin(), tocharlower);
// do the work here // continue with introduction of the overall process thing into the // here all hzip files will be worked on bool bUse_ = true; if( !bExtensionMode )
bUse_ = false;
// catch HelpProcessingException to avoid locking data bases try
{ bool bIndexForExtension = true; // lastly, initialize the indexBuilder if ( (!bExtensionMode || bIndexForExtension) && !helpFiles.empty())
initIndexerPreProcessor();
// here we start our loop over the hzip files. for (autoconst& helpFile : helpFiles)
{ // process one file // streamTable contains the streams in the hzip file
StreamTable streamTable; const std::string &xhpFileName = helpFile;
if (!bExtensionMode && xhpFileName.rfind(".xhp") != xhpFileName.length()-4)
{ // only work on .xhp - files
SAL_WARN("helpcompiler", "ERROR: input list entry '"
<< xhpFileName
<< "' has the wrong extension (only files with extension .xhp are accepted)");
// add once this as its own id.
addBookmark( pFileDbBase_DBHelp, documentPath, fileB, std::string(), jarfileB, titleB);
const std::vector<std::string> *hidlist = streamTable.appl_hidlist.get(); if (hidlist)
{ // now iterate over all elements of the hidlist for (auto & elem : *hidlist)
{
std::string thishid = elem;
//We can be called from the helplinker executable or the extension manager //In the latter case extsource is not used. if( (pExtensionPath && pExtensionPath->length() > 0 && pOfficeHelpPath)
|| !extsource.empty())
{
bExtensionMode = true; if (!extsource.empty())
{ //called from helplinker.exe, pExtensionPath and pOfficeHelpPath //should be NULL
sourceRoot = fs::path(extsource, fs::native);
extensionPath = sourceRoot.toUTF8();
if (extdestination.empty())
{
std::stringstream aStrStream;
aStrStream << "-extlangdest is missing" << std::endl; throw HelpProcessingException( HelpProcessingErrorClass::General, aStrStream.str() );
} else
{ //Convert from system path to file URL!!!
fs::path p(extdestination, fs::native);
extensionDestination = p.toUTF8();
}
} else
{
assert(pExtensionPath); //called from extension manager
extensionPath = *pExtensionPath;
sourceRoot = fs::path(extensionPath);
extensionDestination = *pDestination;
} //check if -src option was used. This option must not be used //when extension help is compiled. if (bSrcOption)
{
std::stringstream aStrStream;
aStrStream << "-src must not be used together with -extsource missing" << std::endl; throw HelpProcessingException( HelpProcessingErrorClass::General, aStrStream.str() );
}
}
if (!bExtensionMode && zipdir.empty())
{
std::stringstream aStrStream;
aStrStream << "no index dir given" << std::endl; throw HelpProcessingException( HelpProcessingErrorClass::General, aStrStream.str() );
}
if ( (!bExtensionMode && idxCaptionStylesheet.empty())
|| (!extsource.empty() && idxCaptionStylesheet.empty()) )
{ //No extension mode and extension mode using commandline //!extsource.empty indicates extension mode using commandline // -idxcaption parameter is required
std::stringstream aStrStream;
aStrStream << "no index caption stylesheet given" << std::endl; throw HelpProcessingException( HelpProcessingErrorClass::General, aStrStream.str() );
} elseif ( bExtensionMode && extsource.empty())
{ //This part is used when compileExtensionHelp is called from the extensions manager. //If extension help is compiled using helplinker in the build process
OUString aIdxCaptionPathFileURL = *pOfficeHelpPath + "/idxcaption.xsl";
if ( (!bExtensionMode && idxContentStylesheet.empty())
|| (!extsource.empty() && idxContentStylesheet.empty()) )
{ //No extension mode and extension mode using commandline //!extsource.empty indicates extension mode using commandline // -idxcontent parameter is required
std::stringstream aStrStream;
aStrStream << "no index content stylesheet given" << std::endl; throw HelpProcessingException( HelpProcessingErrorClass::General, aStrStream.str() );
} elseif ( bExtensionMode && extsource.empty())
{ //If extension help is compiled using helplinker in the build process //then -idxcontent must be supplied //This part is used when compileExtensionHelp is called from the extensions manager.
OUString aIdxContentPathFileURL = *pOfficeHelpPath + "/idxcontent.xsl";
// i83624: Tree files // The following basically checks if the help.tree is well formed XML. // Apparently there have been cases when translations contained // non-well-formed XML in the past.
OUString aTreeFileURL = OUString::Concat(aExtensionLanguageRoot) + "/help.tree";
osl::DirectoryItem aTreeFileItem;
osl::FileBase::RC rcGet = osl::DirectoryItem::get( aTreeFileURL, aTreeFileItem );
osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileSize ); if( rcGet == osl::FileBase::E_None &&
aTreeFileItem.getFileStatus( aFileStatus ) == osl::FileBase::E_None &&
aFileStatus.isValid( osl_FileStatus_Mask_FileSize ) )
{
sal_uInt64 ret, len = aFileStatus.getFileSize();
std::unique_ptr<char[]> s(newchar[ int(len) ]); // the buffer to hold the installed files
osl::File aFile( aTreeFileURL );
(void)aFile.open( osl_File_OpenFlag_Read );
aFile.read( s.get(), len, ret );
aFile.close();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.