/* -*- 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 .
*/
// first argument being 0 should stop the file from being parsed // up to the end (reading all entries) when the required // data (language, conversion type) is found.
rtl::Reference<ConvDicXMLImport> pImport = new ConvDicXMLImport( nullptr );
{ if (bBiDirectional)
pFromRight.reset( new ConvMap ); if (nLang == LANGUAGE_CHINESE_SIMPLIFIED || nLang == LANGUAGE_CHINESE_TRADITIONAL)
pConvPropType.reset( new PropTypeMap );
if( !bExists ) // new empty dictionary
{
bNeedEntries = false; //! create physical representation of an **empty** dictionary //! that could be found by the dictionary-list implementation // (Note: empty dictionaries are not just empty files!)
Save();
}
} else
{
bNeedEntries = false;
}
}
ConvDic::~ConvDic()
{
}
void ConvDic::Load()
{
DBG_ASSERT( !bIsModified, "dictionary is modified. Really do 'Load'?" );
//!! prevent function from being called recursively via HasEntry, AddEntry
bNeedEntries = false;
rtl::Reference<ConvDicXMLImport> pImport = new ConvDicXMLImport( this );
ReadThroughDic( aMainURL, *pImport ); // will implicitly add the entries
bIsModified = false;
}
void ConvDic::Save()
{
DBG_ASSERT( !bNeedEntries, "saving while entries missing" ); if (aMainURL.isEmpty() || bNeedEntries) return;
DBG_ASSERT(!INetURLObject( aMainURL ).HasError(), "invalid URL");
if (!pFromRight && eDirection != ConversionDirection_FROM_LEFT) return uno::Sequence< OUString >();
if (bNeedEntries)
Load();
ConvMap &rConvMap = eDirection == ConversionDirection_FROM_LEFT ?
aFromLeft : *pFromRight;
std::vector<OUString> aRes;
aRes.reserve(rConvMap.size()); for (autoconst& elem : rConvMap)
{
OUString aCurEntry( elem.first ); // skip duplicate entries ( duplicate = duplicate entries // respective to the evaluated side (FROM_LEFT or FROM_RIGHT). // Thus if FROM_LEFT is evaluated for pairs (A,B) and (A,C) // only one entry for A will be returned in the result) if (std::find(aRes.begin(), aRes.end(), aCurEntry) == aRes.end())
aRes.push_back(aCurEntry);
}
// currently we assume that entries with the same left text have the // same PropertyType even if the right text is different... if (pConvPropType)
pConvPropType->emplace( rLeftText, nPropertyType );
bIsModified = true;
}
sal_Int16 nRes = ConversionPropertyType::NOT_DEFINED; if (pConvPropType)
{ // still assuming that entries with same left text have same PropertyType // even if they have different right text...
PropTypeMap::iterator aIt = pConvPropType->find( rLeftText ); if (aIt != pConvPropType->end())
nRes = (*aIt).second;
} return nRes;
}
¤ 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.0.18Bemerkung:
(vorverarbeitet am 2026-06-07)
¤
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 und die Messung sind noch experimentell.