summaryrefslogtreecommitdiffstats
path: root/bf_svx/source/options/svx_asiancfg.cxx
blob: 32d833b7e6175a568e990abf10718e385c43ce42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* -*- 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 .
 */

#include <asiancfg.hxx>
#include <bf_svtools/svarray.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <tools/debug.hxx>
namespace binfilter {

//-----------------------------------------------------------------------------
using namespace utl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;

using ::rtl::OUString;

#define C2U(cChar) OUString::createFromAscii(cChar)
/*N*/ const sal_Char sStartEndCharacters[] = "StartEndCharacters";
/*N*/ const sal_Char sStartCharacters[] = "StartCharacters";
/*N*/ const sal_Char sEndCharacters[] = "EndCharacters";

//-----------------------------------------------------------------------------
/*N*/ struct SvxForbiddenStruct_Impl
/*N*/ {
/*N*/   Locale      aLocale;
/*N*/   OUString    sStartChars;
/*N*/   OUString    sEndChars;
/*N*/ };
//-----------------------------------------------------------------------------
/*N*/ typedef SvxForbiddenStruct_Impl* SvxForbiddenStruct_ImplPtr;
/*N*/ SV_DECL_PTRARR_DEL(SvxForbiddenStructArr, SvxForbiddenStruct_ImplPtr, 2, 2)
/*N*/ SV_IMPL_PTRARR(SvxForbiddenStructArr, SvxForbiddenStruct_ImplPtr);
//-----------------------------------------------------------------------------
/*N*/ struct SvxAsianConfig_Impl
/*N*/ {
/*N*/   sal_Bool    bKerningWesternTextOnly;
/*N*/   sal_Int16   nCharDistanceCompression;
/*N*/
/*N*/   SvxForbiddenStructArr   aForbiddenArr;
/*N*/
/*N*/   SvxAsianConfig_Impl() :
/*N*/       bKerningWesternTextOnly(sal_True),
/*N*/       nCharDistanceCompression(0) {}
/*N*/ };


/*N*/ Sequence<OUString> lcl_GetPropertyNames()
/*N*/ {
/*N*/   Sequence<OUString> aNames(2);
/*N*/   OUString* pNames = aNames.getArray();
/*N*/   pNames[0] = C2U("IsKerningWesternTextOnly");
/*N*/   pNames[1] = C2U("CompressCharacterDistance");
/*N*/   return aNames;;
/*N*/ }
// ---------------------------------------------------------------------------
/*N*/ SvxAsianConfig::SvxAsianConfig(sal_Bool bEnableNotify) :
/*N*/   ::utl::ConfigItem(C2U("Office.Common/AsianLayout")),
/*N*/   pImpl(new SvxAsianConfig_Impl)
/*N*/ {
/*N*/   if(bEnableNotify)
/*N*/       EnableNotification(lcl_GetPropertyNames());
/*N*/   Load();
/*N*/ }


/*N*/ SvxAsianConfig::~SvxAsianConfig()
/*N*/ {
/*N*/   delete pImpl;
/*N*/ }


/*N*/ void SvxAsianConfig::Load()
/*N*/ {
/*N*/   Sequence<Any> aValues = GetProperties(lcl_GetPropertyNames());
/*N*/   const Any* pValues = aValues.getConstArray();
/*N*/   if(pValues[0].hasValue())
/*N*/       pImpl->bKerningWesternTextOnly = *(sal_Bool*) pValues[0].getValue();
/*N*/   pValues[1] >>= pImpl->nCharDistanceCompression;
/*N*/
/*N*/   pImpl->aForbiddenArr.DeleteAndDestroy(0, pImpl->aForbiddenArr.Count());
/*N*/   OUString sPropPrefix(C2U(sStartEndCharacters));
/*N*/   Sequence<OUString> aNodes = GetNodeNames(sPropPrefix);
/*N*/
/*N*/   Sequence<OUString> aPropNames(aNodes.getLength() * 2);
/*N*/   OUString* pNames = aPropNames.getArray();
/*N*/   sal_Int32 nName = 0;
/*N*/   sPropPrefix += C2U("/");
/*N*/   sal_Int32 nNode;
/*N*/   const OUString* pNodes = aNodes.getConstArray();
/*N*/   for(nNode = 0; nNode < aNodes.getLength(); nNode++)
/*N*/   {
/*?*/       OUString sStart(sPropPrefix);
/*?*/       sStart += pNodes[nNode];
/*?*/       sStart += C2U("/");
/*?*/       pNames[nName] = sStart;     pNames[nName++] += C2U("StartCharacters");
/*?*/       pNames[nName] = sStart;     pNames[nName++] += C2U("EndCharacters");
/*N*/   }
/*N*/   Sequence<Any> aNodeValues = GetProperties(aPropNames);
/*N*/   const Any* pNodeValues = aNodeValues.getConstArray();
/*N*/   nName = 0;
/*N*/   for(nNode = 0; nNode < aNodes.getLength(); nNode++)
/*N*/   {
/*?*/       SvxForbiddenStruct_ImplPtr pInsert = new SvxForbiddenStruct_Impl;
/*?*/       pInsert->aLocale.Language = pNodes[nNode].copy(0, 2);
/*?*/       DBG_ASSERT(pInsert->aLocale.Language.getLength(), "illegal language");
/*?*/       pInsert->aLocale.Country = pNodes[nNode].copy(3, 2);
/*?*/
/*?*/       pNodeValues[nName++] >>= pInsert->sStartChars;
/*?*/       pNodeValues[nName++] >>= pInsert->sEndChars;
/*?*/       pImpl->aForbiddenArr.Insert(pInsert, pImpl->aForbiddenArr.Count());
/*N*/   }
/*N*/ }


/*N*/ sal_Bool  SvxAsianConfig::IsKerningWesternTextOnly() const
/*N*/ {
/*N*/   return pImpl->bKerningWesternTextOnly;
/*N*/ }


/*N*/ sal_Int16 SvxAsianConfig::GetCharDistanceCompression() const
/*N*/ {
/*N*/   return pImpl->nCharDistanceCompression;
/*N*/ }


/*N*/ uno::Sequence<lang::Locale> SvxAsianConfig::GetStartEndCharLocales()
/*N*/ {
/*N*/   Sequence<Locale> aRet(pImpl->aForbiddenArr.Count());
/*N*/   Locale* pRet = aRet.getArray();
/*N*/   for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++)
/*N*/   {
/*?*/       pRet[i] = pImpl->aForbiddenArr[i]->aLocale;
/*N*/   }
/*N*/   return aRet;
/*N*/ }

void SvxAsianConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& /*rPropertyNames*/ ) {}
void SvxAsianConfig::Commit() {}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */