Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
fe969399
Kaydet (Commit)
fe969399
authored
May 27, 2011
tarafından
Bjoern Michaelsen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#37290: allow also access to StringList resources
üst
21cdeb7b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
33 deletions
+151
-33
ResourceIndexAccess.cxx
extensions/source/resource/ResourceIndexAccess.cxx
+124
-10
ResourceIndexAccess.hxx
extensions/source/resource/ResourceIndexAccess.hxx
+17
-13
makefile.mk
extensions/source/resource/makefile.mk
+1
-1
res.component
extensions/source/resource/res.component
+2
-2
resourceservices.cxx
extensions/source/resource/resourceservices.cxx
+7
-7
No files found.
extensions/source/resource/Resource
String
IndexAccess.cxx
→
extensions/source/resource/ResourceIndexAccess.cxx
Dosyayı görüntüle @
fe969399
...
...
@@ -28,8 +28,11 @@
* instead of those above.
*/
#include <Resource
String
IndexAccess.hxx>
#include <ResourceIndexAccess.hxx>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <comphelper/stlunosequence.hxx>
#include <osl/mutex.hxx>
#include <tools/rcid.h>
#include <tools/resary.hxx>
...
...
@@ -39,34 +42,82 @@
using
namespace
::
extensions
::
resource
;
using
namespace
::
com
::
sun
::
star
::
uno
;
using
namespace
::
com
::
sun
::
star
::
lang
;
using
namespace
::
com
::
sun
::
star
::
beans
;
using
namespace
::
com
::
sun
::
star
::
container
;
using
::
rtl
::
OUString
;
using
::
comphelper
::
stl_begin
;
using
::
comphelper
::
stl_end
;
using
::
rtl
::
OString
;
using
::
rtl
::
OUString
;
using
::
rtl
::
OUStringToOString
;
namespace
{
static
::
std
::
auto
_ptr
<
ResMgr
>
GetResMgr
(
Sequence
<
Any
>
const
&
rArgs
)
static
::
boost
::
shared
_ptr
<
ResMgr
>
GetResMgr
(
Sequence
<
Any
>
const
&
rArgs
)
{
if
(
rArgs
.
getLength
()
!=
1
)
return
::
std
::
auto
_ptr
<
ResMgr
>
();
return
::
boost
::
shared
_ptr
<
ResMgr
>
();
OUString
sFilename
;
rArgs
[
0
]
>>=
sFilename
;
SolarMutexGuard
aGuard
;
const
OString
sEncName
(
OUStringToOString
(
sFilename
,
osl_getThreadTextEncoding
()));
return
::
std
::
auto
_ptr
<
ResMgr
>
(
ResMgr
::
CreateResMgr
(
sEncName
));
return
::
boost
::
shared
_ptr
<
ResMgr
>
(
ResMgr
::
CreateResMgr
(
sEncName
));
}
}
class
ResourceIndexAccessBase
:
public
cppu
::
WeakImplHelper1
<
::
com
::
sun
::
star
::
container
::
XIndexAccess
>
{
public
:
ResourceIndexAccessBase
(
::
boost
::
shared_ptr
<
ResMgr
>
pResMgr
)
:
m_pResMgr
(
pResMgr
)
{
OSL_ENSURE
(
m_pResMgr
,
"no ressource manager given"
);
}
// XIndexAccess
virtual
::
sal_Int32
SAL_CALL
getCount
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
return
m_pResMgr
.
get
()
?
SAL_MAX_UINT16
:
0
;
};
// XElementAccess
virtual
::
sal_Bool
SAL_CALL
hasElements
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
return
static_cast
<
bool
>
(
m_pResMgr
.
get
());
};
ResourceStringIndexAccess
::
ResourceStringIndexAccess
(
Sequence
<
Any
>
const
&
rArgs
,
Reference
<
XComponentContext
>
const
&
)
protected
:
// m_pResMgr should never be NULL
const
::
boost
::
shared_ptr
<
ResMgr
>
m_pResMgr
;
};
class
ResourceStringIndexAccess
:
public
ResourceIndexAccessBase
{
public
:
ResourceStringIndexAccess
(
::
boost
::
shared_ptr
<
ResMgr
>
pResMgr
)
:
ResourceIndexAccessBase
(
pResMgr
)
{}
// XIndexAccess
virtual
::
com
::
sun
::
star
::
uno
::
Any
SAL_CALL
getByIndex
(
::
sal_Int32
Index
)
throw
(
::
com
::
sun
::
star
::
lang
::
IndexOutOfBoundsException
,
::
com
::
sun
::
star
::
lang
::
WrappedTargetException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
// XElementAccessBase
virtual
::
com
::
sun
::
star
::
uno
::
Type
SAL_CALL
getElementType
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
return
::
getCppuType
(
reinterpret_cast
<
::
rtl
::
OUString
*>
(
NULL
));
};
};
class
ResourceStringListIndexAccess
:
public
ResourceIndexAccessBase
{
public
:
ResourceStringListIndexAccess
(
::
boost
::
shared_ptr
<
ResMgr
>
pResMgr
)
:
ResourceIndexAccessBase
(
pResMgr
)
{}
// XIndexAccess
virtual
::
com
::
sun
::
star
::
uno
::
Any
SAL_CALL
getByIndex
(
::
sal_Int32
Index
)
throw
(
::
com
::
sun
::
star
::
lang
::
IndexOutOfBoundsException
,
::
com
::
sun
::
star
::
lang
::
WrappedTargetException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
// XElementAccessBase
virtual
::
com
::
sun
::
star
::
uno
::
Type
SAL_CALL
getElementType
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
return
::
getCppuType
(
reinterpret_cast
<
Sequence
<
PropertyValue
>
*
>
(
NULL
));
};
};
}
ResourceIndexAccess
::
ResourceIndexAccess
(
Sequence
<
Any
>
const
&
rArgs
,
Reference
<
XComponentContext
>
const
&
)
:
m_pResMgr
(
GetResMgr
(
rArgs
))
{};
Reference
<
XInterface
>
initResource
StringIndexAccess
(
ResourceStringIndexAccess
*
pResourceString
IndexAccess
)
Reference
<
XInterface
>
initResource
IndexAccess
(
ResourceIndexAccess
*
pResource
IndexAccess
)
{
Reference
<
XInterface
>
xResult
(
static_cast
<
cppu
::
OWeakObject
*>
(
pResource
String
IndexAccess
));
if
(
!
pResource
String
IndexAccess
->
hasElements
())
Reference
<
XInterface
>
xResult
(
static_cast
<
cppu
::
OWeakObject
*>
(
pResourceIndexAccess
));
if
(
!
pResourceIndexAccess
->
hasElements
())
// xResult does not help the client to analyse the problem
// and will crash on getByIndex calls, better just give back an empty Reference
// so that such ResourceStringIndexAccess instances are never release into the wild
...
...
@@ -76,6 +127,45 @@ Reference<XInterface> initResourceStringIndexAccess(ResourceStringIndexAccess* p
return
xResult
;
}
Any
SAL_CALL
ResourceIndexAccess
::
getByName
(
const
OUString
&
aName
)
throw
(
NoSuchElementException
,
WrappedTargetException
,
RuntimeException
)
{
const
Sequence
<
OUString
>
aNames
(
getElementNames
());
Reference
<
XIndexAccess
>
xResult
;
switch
(
::
std
::
find
(
stl_begin
(
aNames
),
stl_end
(
aNames
),
aName
)
-
stl_begin
(
aNames
))
{
case
0
:
xResult
=
Reference
<
XIndexAccess
>
(
new
ResourceStringIndexAccess
(
m_pResMgr
));
break
;
case
1
:
xResult
=
Reference
<
XIndexAccess
>
(
new
ResourceStringListIndexAccess
(
m_pResMgr
));
break
;
default
:
throw
NoSuchElementException
();
}
return
makeAny
(
xResult
);
}
Sequence
<
OUString
>
SAL_CALL
ResourceIndexAccess
::
getElementNames
(
)
throw
(
RuntimeException
)
{
static
Sequence
<
OUString
>
aResult
;
if
(
aResult
.
getLength
()
==
0
)
{
aResult
.
realloc
(
2
);
aResult
[
0
]
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"String"
));
aResult
[
1
]
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"StringList"
));
}
return
aResult
;
}
::
sal_Bool
SAL_CALL
ResourceIndexAccess
::
hasByName
(
const
OUString
&
aName
)
throw
(
RuntimeException
)
{
const
Sequence
<
OUString
>
aNames
(
getElementNames
());
return
(
::
std
::
find
(
stl_begin
(
aNames
),
stl_end
(
aNames
),
aName
)
!=
stl_end
(
aNames
));
}
Any
SAL_CALL
ResourceStringIndexAccess
::
getByIndex
(
sal_Int32
nIdx
)
throw
(
IndexOutOfBoundsException
,
WrappedTargetException
,
RuntimeException
)
{
...
...
@@ -91,4 +181,28 @@ Any SAL_CALL ResourceStringIndexAccess::getByIndex(sal_Int32 nIdx)
return
makeAny
(
OUString
(
String
(
aId
)));
}
Any
SAL_CALL
ResourceStringListIndexAccess
::
getByIndex
(
sal_Int32
nIdx
)
throw
(
IndexOutOfBoundsException
,
WrappedTargetException
,
RuntimeException
)
{
if
(
nIdx
>
SAL_MAX_UINT16
||
nIdx
<
0
)
throw
IndexOutOfBoundsException
();
SolarMutexGuard
aGuard
;
const
ResId
aId
(
static_cast
<
sal_uInt16
>
(
nIdx
),
*
m_pResMgr
);
aId
.
SetRT
(
RSC_STRINGARRAY
);
if
(
!
m_pResMgr
->
IsAvailable
(
aId
))
throw
RuntimeException
(
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"string list ressource for id not available"
)),
Reference
<
XInterface
>
());
const
ResStringArray
aStringList
(
aId
);
Sequence
<
PropertyValue
>
aPropList
(
aStringList
.
Count
());
for
(
sal_Int32
nCount
=
0
;
nCount
!=
aPropList
.
getLength
();
++
nCount
)
{
aPropList
[
nCount
].
Name
=
aStringList
.
GetString
(
nCount
);
aPropList
[
nCount
].
Handle
=
-
1
;
aPropList
[
nCount
].
Value
<<=
aStringList
.
GetValue
(
nCount
);
aPropList
[
nCount
].
State
=
PropertyState_DIRECT_VALUE
;
}
return
makeAny
(
aPropList
);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
extensions/source/resource/Resource
String
IndexAccess.hxx
→
extensions/source/resource/ResourceIndexAccess.hxx
Dosyayı görüntüle @
fe969399
...
...
@@ -33,39 +33,43 @@
#include "precompiled_extensions.hxx"
#include <com/sun/star/container/XIndexAccess.hpp>
#include <boost/shared_ptr.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/XInterface.hpp>
#include <cppuhelper/implbase1.hxx>
#include <memory>
class
ResMgr
;
namespace
extensions
{
namespace
resource
{
class
ResourceStringIndexAccess
:
public
cppu
::
WeakImplHelper1
<
::
com
::
sun
::
star
::
container
::
XIndexAccess
>
/** This class provides access to tools library text resources */
class
ResourceIndexAccess
:
public
cppu
::
WeakImplHelper1
<
::
com
::
sun
::
star
::
container
::
XNameAccess
>
{
public
:
ResourceStringIndexAccess
(
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
uno
::
Any
>
const
&
rArgs
,
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
const
&
);
// XIndexAccess
virtual
::
sal_Int32
SAL_CALL
getCount
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
return
m_pResMgr
.
get
()
?
SAL_MAX_UINT16
:
0
;
};
virtual
::
com
::
sun
::
star
::
uno
::
Any
SAL_CALL
getByIndex
(
::
sal_Int32
Index
)
throw
(
::
com
::
sun
::
star
::
lang
::
IndexOutOfBoundsException
,
::
com
::
sun
::
star
::
lang
::
WrappedTargetException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
/** The ctor takes a sequence with one element: the name of the resource, e.g. svt */
ResourceIndexAccess
(
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
uno
::
Any
>
const
&
rArgs
,
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
const
&
);
// XNameAccess
// The XNameAccess provides access to two named elements:
// "String" returns a XIndexAccess to String resources
// "StringList" returns a XIndexAccess to StringList/StringArray resources
virtual
::
com
::
sun
::
star
::
uno
::
Any
SAL_CALL
getByName
(
const
::
rtl
::
OUString
&
aName
)
throw
(
::
com
::
sun
::
star
::
container
::
NoSuchElementException
,
::
com
::
sun
::
star
::
lang
::
WrappedTargetException
,
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
virtual
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
rtl
::
OUString
>
SAL_CALL
getElementNames
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
virtual
::
sal_Bool
SAL_CALL
hasByName
(
const
::
rtl
::
OUString
&
aName
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
);
// XElementAccess
virtual
::
com
::
sun
::
star
::
uno
::
Type
SAL_CALL
getElementType
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
return
::
getCppuType
(
reinterpret_cast
<
::
rtl
::
OUString
*>
(
NULL
));
};
{
return
::
getCppuType
(
reinterpret_cast
<
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XInterface
>
*>
(
NULL
));
};
virtual
::
sal_Bool
SAL_CALL
hasElements
(
)
throw
(
::
com
::
sun
::
star
::
uno
::
RuntimeException
)
{
return
static_cast
<
bool
>
(
m_pResMgr
.
get
());
};
private
:
// m_pResMgr should never be NULL
, see initResourceStringIndexAccess
const
::
std
::
auto
_ptr
<
ResMgr
>
m_pResMgr
;
// m_pResMgr should never be NULL
const
::
boost
::
shared
_ptr
<
ResMgr
>
m_pResMgr
;
};
}}
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XInterface
>
initResource
StringIndexAccess
(
::
extensions
::
resource
::
ResourceString
IndexAccess
*
);
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XInterface
>
initResource
IndexAccess
(
::
extensions
::
resource
::
Resource
IndexAccess
*
);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
extensions/source/resource/makefile.mk
Dosyayı görüntüle @
fe969399
...
...
@@ -40,7 +40,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files --------------------------------------------------------
SLOFILES
=
\
$(SLO)$/
Resource
String
IndexAccess.obj
\
$(SLO)$/
ResourceIndexAccess.obj
\
$(SLO)$/
oooresourceloader.obj
\
$(SLO)$/
resourceservices.obj
...
...
extensions/source/resource/res.component
Dosyayı görüntüle @
fe969399
...
...
@@ -32,7 +32,7 @@
<service
name=
"com.sun.star.resource.OfficeResourceLoader"
/>
<singleton
name=
"com.sun.star.resource.OfficeResourceLoader"
/>
</implementation>
<implementation
name=
"org.libreoffice.extensions.resource.Resource
String
IndexAccess"
>
<service
name=
"org.libreoffice.resource.Resource
String
IndexAccess"
/>
<implementation
name=
"org.libreoffice.extensions.resource.ResourceIndexAccess"
>
<service
name=
"org.libreoffice.resource.ResourceIndexAccess"
/>
</implementation>
</component>
extensions/source/resource/resourceservices.cxx
Dosyayı görüntüle @
fe969399
...
...
@@ -30,20 +30,20 @@
#include "precompiled_extensions.hxx"
#include <Resource
String
IndexAccess.hxx>
#include <ResourceIndexAccess.hxx>
#include <oooresourceloader.hxx>
#include <comphelper/servicedecl.hxx>
#include <uno/environment.h>
namespace
sdecl
=
::
comphelper
::
service_decl
;
sdecl
::
class_
<
::
extensions
::
resource
::
Resource
StringIndexAccess
,
sdecl
::
with_args
<
true
>
>
ResourceString
IndexAccessServiceImpl
;
sdecl
::
class_
<
::
extensions
::
resource
::
Resource
IndexAccess
,
sdecl
::
with_args
<
true
>
>
Resource
IndexAccessServiceImpl
;
sdecl
::
class_
<
::
extensions
::
resource
::
OpenOfficeResourceLoader
>
OpenOfficeResourceLoaderServiceImpl
;
const
sdecl
::
ServiceDecl
Resource
String
IndexAccessDecl
(
Resource
String
IndexAccessServiceImpl
,
"org.libreoffice.extensions.resource.Resource
String
IndexAccess"
,
"org.libreoffice.resource.Resource
String
IndexAccess"
);
const
sdecl
::
ServiceDecl
ResourceIndexAccessDecl
(
ResourceIndexAccessServiceImpl
,
"org.libreoffice.extensions.resource.ResourceIndexAccess"
,
"org.libreoffice.resource.ResourceIndexAccess"
);
const
sdecl
::
ServiceDecl
OpenOfficeResourceLoaderDecl
(
OpenOfficeResourceLoaderServiceImpl
,
...
...
@@ -51,7 +51,7 @@ const sdecl::ServiceDecl OpenOfficeResourceLoaderDecl(
"com.sun.star.resource.OfficeResourceLoader"
);
COMPHELPER_SERVICEDECL_EXPORTS2
(
Resource
String
IndexAccessDecl
,
ResourceIndexAccessDecl
,
OpenOfficeResourceLoaderDecl
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment