2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-09-27 13:52:10 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2001-08-23 10:45:30 +00:00
|
|
|
|
2013-11-05 02:21:42 +01:00
|
|
|
#ifndef INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
|
|
|
|
#define INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
|
2013-05-02 15:06:23 +02:00
|
|
|
|
2012-02-08 14:34:22 +01:00
|
|
|
#include "sal/config.h"
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
2001-08-23 10:45:30 +00:00
|
|
|
|
2013-05-02 15:06:23 +02:00
|
|
|
/// Parser for *.xrm and description.xml files
|
2001-08-23 10:45:30 +00:00
|
|
|
class XRMResParser
|
|
|
|
{
|
|
|
|
private:
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sGID;
|
|
|
|
OString sLID;
|
2001-08-23 10:45:30 +00:00
|
|
|
|
2014-02-15 17:06:22 +01:00
|
|
|
bool bError;
|
|
|
|
bool bText;
|
2001-08-23 10:45:30 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sCurrentOpenTag;
|
|
|
|
OString sCurrentCloseTag;
|
|
|
|
OString sCurrentText;
|
2001-08-23 10:45:30 +00:00
|
|
|
protected:
|
2015-03-27 10:50:38 +02:00
|
|
|
static OString GetAttribute( const OString &rToken, const OString &rAttribute );
|
|
|
|
static void Error( const OString &rError );
|
2001-08-23 10:45:30 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
virtual void Output( const OString& rOutput )=0;
|
2011-10-05 21:54:56 +02:00
|
|
|
virtual void WorkOnDesc(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
OString &rText
|
2011-10-05 21:54:56 +02:00
|
|
|
)=0;
|
2001-08-23 10:45:30 +00:00
|
|
|
virtual void WorkOnText(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
OString &rText
|
2006-06-19 16:20:31 +00:00
|
|
|
)=0;
|
2001-08-23 10:45:30 +00:00
|
|
|
virtual void EndOfText(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
const OString &rCloseTag
|
2006-06-19 16:20:31 +00:00
|
|
|
)=0;
|
2001-08-23 10:45:30 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OString GetGID() { return sGID; }
|
|
|
|
OString GetLID() { return sLID; }
|
2001-08-23 10:45:30 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
XRMResParser();
|
|
|
|
virtual ~XRMResParser();
|
|
|
|
|
|
|
|
int Execute( int nToken, char * pToken );
|
|
|
|
|
2014-02-15 17:06:22 +01:00
|
|
|
void SetError( bool bErr = true ) { bError = bErr; }
|
|
|
|
bool GetError() { return bError; }
|
2001-08-23 10:45:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-02 15:06:23 +02:00
|
|
|
/// Export strings from *.xrm and description.xml files
|
2013-03-15 15:42:05 +01:00
|
|
|
class XRMResExport : public XRMResParser
|
2001-08-23 10:45:30 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
ResData *pResData;
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sPath;
|
2013-03-15 15:42:05 +01:00
|
|
|
PoOfstream pOutputStream;
|
2001-08-23 10:45:30 +00:00
|
|
|
protected:
|
2011-10-05 21:54:56 +02:00
|
|
|
void WorkOnDesc(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
OString &rText
|
2014-03-26 16:37:00 +01:00
|
|
|
) SAL_OVERRIDE;
|
2006-06-19 16:20:31 +00:00
|
|
|
void WorkOnText(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
OString &rText
|
2014-03-26 16:37:00 +01:00
|
|
|
) SAL_OVERRIDE;
|
2006-06-19 16:20:31 +00:00
|
|
|
void EndOfText(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
const OString &rCloseTag
|
2014-03-26 16:37:00 +01:00
|
|
|
) SAL_OVERRIDE;
|
|
|
|
void Output( const OString& rOutput ) SAL_OVERRIDE;
|
2001-08-23 10:45:30 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
XRMResExport(
|
2013-03-25 11:57:39 +01:00
|
|
|
const OString &rOutputFile,
|
|
|
|
const OString &rFilePath
|
2001-08-23 10:45:30 +00:00
|
|
|
);
|
|
|
|
virtual ~XRMResExport();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-02 15:06:23 +02:00
|
|
|
/// Merge strings to *.xrm and description.xml files
|
2013-03-15 15:42:05 +01:00
|
|
|
class XRMResMerge : public XRMResParser
|
2001-08-23 10:45:30 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
MergeDataFile *pMergeDataFile;
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sFilename;
|
2001-08-23 10:45:30 +00:00
|
|
|
ResData *pResData;
|
2013-03-15 15:42:05 +01:00
|
|
|
std::ofstream pOutputStream;
|
2013-04-23 23:20:53 +02:00
|
|
|
std::vector<OString> aLanguages;
|
2001-08-23 10:45:30 +00:00
|
|
|
|
|
|
|
protected:
|
2011-10-05 21:54:56 +02:00
|
|
|
void WorkOnDesc(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
OString &rText
|
2014-03-26 16:37:00 +01:00
|
|
|
) SAL_OVERRIDE;
|
2006-06-19 16:20:31 +00:00
|
|
|
void WorkOnText(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
OString &rText
|
2014-03-26 16:37:00 +01:00
|
|
|
) SAL_OVERRIDE;
|
2006-06-19 16:20:31 +00:00
|
|
|
void EndOfText(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rOpenTag,
|
|
|
|
const OString &rCloseTag
|
2014-03-26 16:37:00 +01:00
|
|
|
) SAL_OVERRIDE;
|
|
|
|
void Output( const OString& rOutput ) SAL_OVERRIDE;
|
2001-08-23 10:45:30 +00:00
|
|
|
public:
|
|
|
|
XRMResMerge(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString &rMergeSource,
|
|
|
|
const OString &rOutputFile,
|
|
|
|
const OString &rFilename
|
2001-08-23 10:45:30 +00:00
|
|
|
);
|
|
|
|
virtual ~XRMResMerge();
|
|
|
|
};
|
|
|
|
|
2013-11-05 02:21:42 +01:00
|
|
|
#endif // INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
|
2013-05-02 15:06:23 +02:00
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|