2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
re-base on ALv2 code. Includes (at least) relevant parts of:
linecap: Reintegrating finished LineCap feature
Patch contributed by Regina Henschel
http://svn.apache.org/viewvc?view=revision&revision=1232507
Patches contributed by Sven Jacobi
impress212: #i81610# fixed animation export
http://svn.apache.org/viewvc?view=revision&revision=1167620
impress212: drawinglayer gbuild environment changes
http://svn.apache.org/viewvc?view=revision&revision=1167627
http://svn.apache.org/viewvc?view=revision&revision=1167628
impress212: DffPropSet -> minor code improvements, removing table
http://svn.apache.org/viewvc?view=revision&revision=1167634
impress212: #158494# fixed excel import (text rotation)
http://svn.apache.org/viewvc?view=revision&revision=1167638
Patches contributed by Armin Le Grand
Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement
http://svn.apache.org/viewvc?view=revision&revision=1220836
#118728# changed indentifying definitions for Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1229961
#118838# LineGeometry creation for complicated cases optimized to
create single Polygons
http://svn.apache.org/viewvc?view=revision&revision=1236232
#119176# corrected file type detection for SVG for svg files
without xml header
http://svn.apache.org/viewvc?view=revision&revision=1309445
#118728# Extended Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1230531
#118529# solve break converters and convert commands for OLEs and images
http://svn.apache.org/viewvc?view=revision&revision=1186168
svg: added WaE changes from branch svgreplacement to trunc
http://svn.apache.org/viewvc?view=revision&revision=1222974
svg: corrected missing member initialization
http://svn.apache.org/viewvc?view=revision&revision=1226134
fix for #118525#: Using primitives for chart sub-geometry visualisation
http://svn.apache.org/viewvc?view=revision&revision=1226879
#118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert
metafiles to bitmapEx ...
http://svn.apache.org/viewvc?view=revision&revision=1293316
fix for #118525#: removed no longer used variable maOriginalMapMode, one
more exception eliminated
http://svn.apache.org/viewvc?view=revision&revision=1227097
#16758# Added buffering to the VDev usages of the VclProcessor2D derivates...
http://svn.apache.org/viewvc?view=revision&revision=1229521
#116758# Secured VDev buffer device to Vcl deinit
http://svn.apache.org/viewvc?view=revision&revision=1230574
#116758# added remembering allocated VDevs for VDevBuffer to be able to also
delete these when vcl goes down; it should never happen, but You never know
http://svn.apache.org/viewvc?view=revision&revision=1230927
#118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive
representation instead of TransparencePrimitive2D
http://svn.apache.org/viewvc?view=revision&revision=1231198
#118822# secured 3D geometry creation (slices) by subdividing the 2D
source polyPolygon early
http://svn.apache.org/viewvc?view=revision&revision=1234749
#118829# enhanced Svg gradient quality, obstacles avoided
http://svn.apache.org/viewvc?view=revision&revision=1235361
#118834# Unified usage of TextBreakupHelper as single tooling class
for i18n text primitive breakup
http://svn.apache.org/viewvc?view=revision&revision=1236110
#118853# added square pixel size limit to conversion of
TransparencePrimitive2D to Metafile action
http://svn.apache.org/viewvc?view=revision&revision=1237656
#118824# coreccted mirroring and boundrect when the graphicmanager
is used for bitmap output
http://svn.apache.org/viewvc?view=revision&revision=1240097
#115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for
various optimization scenarios
http://svn.apache.org/viewvc?view=revision&revision=1241434
#118783# Corrected errors in ID strings, corrected Svg line/fill export,
corrected polygon close state
http://svn.apache.org/viewvc?view=revision&revision=1232006
#118796# corrected null-pointer usage in SVG text exporter
http://svn.apache.org/viewvc?view=revision&revision=1240262
#118729# Use GraphicStreamUrl and GraphicUrl to allow multi image
import with linked graphics, too
http://svn.apache.org/viewvc?view=revision&revision=1229962
#118898# corrected error in GDIMetaFile::GetBoundRect in handling
MetaFloatTransparentAction
http://svn.apache.org/viewvc?view=revision&revision=1293349
#118855# Corrected handling of possibly created empty clipRegions
after PolyPolygon clipping
http://svn.apache.org/viewvc?view=revision&revision=1237725
#115962# Better (but not yet optimal, see comments in task) handling
of MetaFloatTransparentAction in PDF export
http://svn.apache.org/viewvc?view=revision&revision=1241078
IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ...
http://svn.apache.org/viewvc?view=revision&revision=1200879
118779# Added svg content streaming in/out to ImpGraphic stream operators
http://svn.apache.org/viewvc?view=revision&revision=1231908
linecap: correctons for WaE and mac drawing
http://svn.apache.org/viewvc?view=revision&revision=1232793
svg: uses current system Dpi for Svg replacement image creation
http://svn.apache.org/viewvc?view=revision&revision=1233948
Patches contributed by Mathias Bauer (and others)
gnumake4 work variously
http://svn.apache.org/viewvc?view=revision&revision=1394326
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1394326
Remove duplicate header includes.
cws mba34issues01: #i117720#: convert assertion into warning
http://svn.apache.org/viewvc?view=revision&revision=1172352
118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand.
http://svn.apache.org/viewvc?view=revision&revision=1182166
cws mba34issues01: #i117714#: remove assertion
http://svn.apache.org/viewvc?view=revision&revision=1172357
Patch contributed by Jurgen Schmidt
add some additional checks to ensure proper reading operations
http://svn.apache.org/viewvc?view=revision&revision=1209022
mostly prefer our stream / bounds checking work.
Patches contributed by Herbert Duerr
#i118816# add clarifying comment regarding Font::*Color*() methods
http://svn.apache.org/viewvc?view=revision&revision=1233833
extend macro->string handling for empty strings
http://svn.apache.org/viewvc?view=revision&revision=1175801
avoid magic constants for SALCOLOR_NONE
http://svn.apache.org/viewvc?view=revision&revision=1177543
initialize slant properly in ImplFontMetricData constructor (author=iorsh)
http://svn.apache.org/viewvc?view=revision&revision=1177551
#i118675# make check for extension updates more stable
http://svn.apache.org/viewvc?view=revision&revision=1214797
#a118617# remove VBasicEventListener.dll binary
There are no known users depending on its CLSID
http://svn.apache.org/viewvc?view=revision&revision=1203697
Patches contributed by Ariel Constenla-Haile
Fix build breaker on Linux/gcc
http://svn.apache.org/viewvc?view=revision&revision=1221104
Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG
http://svn.apache.org/viewvc?view=revision&revision=1215559
Patches contributed by Oliver-Rainer Wittmann
sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider
instances of <SwFlyDrawObj>
http://svn.apache.org/viewvc?view=revision&revision=1172120
sw34bf06: #i117783# - Writer's implementation of XPagePrintable -
apply print settings to new printing routines
http://svn.apache.org/viewvc?view=revision&revision=1172115
gnumake4 work variously from Hans-Joachim Lankenau
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1396782
http://svn.apache.org/viewvc?view=revision&revision=1394707
plus some amount of re-splitting of legacy headers.
Patch contributed by Pavel Janik
WaE: Remove unused variables.
http://svn.apache.org/viewvc?view=revision&revision=1230697
Patches contributed by Takashi Ono
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
Patch contributed by Christian Lippka
impress212: #i98044# re enable Text menu for outline and title shapes
http://svn.apache.org/viewvc?view=revision&revision=1167639
Patch contributed by Andre Fischer
118674: Made category B code optional and disabled by default.
http://svn.apache.org/viewvc?view=revision&revision=1215131
118881: Ignore empty paragraphs after bullets.
http://svn.apache.org/viewvc?view=revision&revision=1296205
Patches contributed by Philipp Lohmann
ooo340fixes: #i117780# use rtl allocator
http://svn.apache.org/viewvc?view=revision&revision=1172087
ooo34gsl02: #i117807# fix an off by one error (index actually
inside the pfb section header)
http://svn.apache.org/viewvc?view=revision&revision=1167576
various cleanups, related compilation fixes, warning cleanups, re-working
of obsolete stl template pieces to use boost instead, changed string
classes, re-adapt KDE about data, about dialog, fixing warnings,
and other fixes & improvements.
Disable svg import / render for about/ branding code-paths for now.
Restore full icon theme set.
Remove OS/2 conditionals and sources.
Remove conflicting gtk/full-screen monitors support.
Retain existing svg rasterizer files - temporarily disabled.
Standardize stringificaiton and fixup dllpostfix issues.
Rename SvgGradientHelper::== to equalTo to avoid overloading issues.
Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +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 .
|
|
|
|
*/
|
2006-09-16 12:23:57 +00:00
|
|
|
|
2017-10-23 22:41:56 +02:00
|
|
|
#include <sal/config.h>
|
2014-04-13 23:44:29 +02:00
|
|
|
|
2017-10-23 22:41:56 +02:00
|
|
|
#include <cppuhelper/factory.hxx>
|
|
|
|
#include <cppuhelper/implementationentry.hxx>
|
2015-08-04 17:52:31 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2013-10-22 11:47:01 -02:00
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
2017-10-23 22:41:56 +02:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#include <com/sun/star/inspection/XStringRepresentation.hpp>
|
|
|
|
#include <com/sun/star/lang/XInitialization.hpp>
|
|
|
|
#include <com/sun/star/script/CannotConvertException.hpp>
|
|
|
|
#include <com/sun/star/script/XTypeConverter.hpp>
|
2007-07-06 07:55:00 +00:00
|
|
|
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
|
|
|
|
#include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
|
|
|
|
#include <com/sun/star/beans/XIntrospection.hpp>
|
2004-11-16 11:12:56 +00:00
|
|
|
#include <com/sun/star/util/DateTime.hpp>
|
|
|
|
#include <com/sun/star/util/Date.hpp>
|
|
|
|
#include <com/sun/star/util/Time.hpp>
|
2018-08-18 18:24:16 +02:00
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
2007-07-06 07:55:00 +00:00
|
|
|
#include <connectivity/dbconversion.hxx>
|
2018-05-27 14:07:43 +02:00
|
|
|
#include <osl/diagnose.h>
|
2018-07-28 18:01:28 +02:00
|
|
|
#include <rtl/ustrbuf.hxx>
|
2018-07-27 09:42:16 +02:00
|
|
|
#include <sal/log.hxx>
|
2017-10-23 22:41:56 +02:00
|
|
|
#include <strings.hrc>
|
|
|
|
#include <yesno.hrc>
|
2014-04-13 23:44:29 +02:00
|
|
|
#include "pcrservices.hxx"
|
2004-11-16 11:12:56 +00:00
|
|
|
#include <comphelper/types.hxx>
|
2007-07-06 07:55:00 +00:00
|
|
|
#include "modulepcr.hxx"
|
2004-11-16 11:12:56 +00:00
|
|
|
|
|
|
|
#include <functional>
|
INTEGRATION: CWS pbrwuno (1.3.88); FILE MERGED
2005/12/19 12:22:19 fs 1.3.88.6: #i53095# also allow for BYTE sequences
2005/10/24 08:42:07 fs 1.3.88.5: start making the handlers full-fledged components, with using a new infrastructure replacing extensions/source/inc/componentmodule.*
2005/10/17 12:20:20 fs 1.3.88.4: make StringListField exchange a sequence< string >
2005/10/05 07:11:39 fs 1.3.88.3: RESYNC: (1.3-1.4); FILE MERGED
2005/08/18 12:44:35 fs 1.3.88.2: #i53095#, phase 2
moved (nearly) all property handling to dedicated handlers, the controller is
now simply managing a set of handlers
open issues for making the property browser completely generic:
- target page for a property - at the moment, the pbrw uses form-specific
knowledge
- relative position of properties. Again, the pbrw uses the OPropertyInfoService
which is not generic
- isComposeable for a given property. Also OPropertyInfoService-dependent ATM
- help ids of pages and the pbrw as a whole. They're hard-coded at the moment
other open issues:
everything in the code which is tagged with TOD/UNOize. Those are items which
do not immediately hinder phase 3 (real UNOization, i.e. definition of new
UNO interfaces for the handlers, the controller, and so on), but need to be
addressed in phase 4 (knit lose ends)
2005/08/09 14:00:08 fs 1.3.88.1: #i53095# phase 1:
- don't use strings to transver values between controls and introspectee, but Anys
- first version of a dedicated property handler for form-component-related properties
(not yet completed)
known regressions over previous phase:
- handlers for events not yet implemented, thus some assertions
- click handlers for form-component-related properties do not yet work,
thus the browse buttons mostly do not work
2006-03-14 10:33:17 +00:00
|
|
|
#include <algorithm>
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
// component helper namespace
|
|
|
|
namespace comp_StringRepresentation {
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
// component and service helper functions:
|
2018-09-15 19:13:19 +02:00
|
|
|
static OUString _getImplementationName();
|
|
|
|
static uno::Sequence< OUString > _getSupportedServiceNames();
|
|
|
|
static uno::Reference< uno::XInterface > _create( uno::Reference< uno::XComponentContext > const & context );
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
} // closing component helper namespace
|
|
|
|
|
|
|
|
|
|
|
|
namespace pcr{
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
namespace {
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
class StringRepresentation:
|
2015-08-04 17:52:31 +09:00
|
|
|
public ::cppu::WeakImplHelper<
|
2007-07-06 07:55:00 +00:00
|
|
|
lang::XServiceInfo,
|
|
|
|
inspection::XStringRepresentation,
|
2016-04-09 17:07:54 +02:00
|
|
|
lang::XInitialization>
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
public:
|
|
|
|
explicit StringRepresentation(uno::Reference< uno::XComponentContext > const & context);
|
2016-04-09 17:07:54 +02:00
|
|
|
StringRepresentation (const StringRepresentation&) = delete;
|
|
|
|
StringRepresentation& operator=(const StringRepresentation&) = delete;
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
// lang::XServiceInfo:
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual OUString SAL_CALL getImplementationName() override;
|
|
|
|
virtual sal_Bool SAL_CALL supportsService(const OUString & ServiceName) override;
|
|
|
|
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
// inspection::XStringRepresentation:
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual OUString SAL_CALL convertToControlValue(const uno::Any & PropertyValue) override;
|
|
|
|
virtual uno::Any SAL_CALL convertToPropertyValue(const OUString & ControlValue, const uno::Type & ControlValueType) override;
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
// lang::XInitialization:
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void SAL_CALL initialize(const uno::Sequence< uno::Any > & aArguments) override;
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
private:
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~StringRepresentation() override {}
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
/** converts a generic value into a string representation
|
|
|
|
|
|
|
|
If you want to convert values whose string representation does not depend
|
|
|
|
on a concrete property, use this version
|
|
|
|
|
|
|
|
@return <TRUE/>
|
|
|
|
if and only if the value could be converted
|
|
|
|
*/
|
2015-04-15 13:17:16 +02:00
|
|
|
static bool convertGenericValueToString(
|
2007-07-06 07:55:00 +00:00
|
|
|
const uno::Any& _rValue,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString& _rStringRep
|
2007-07-06 07:55:00 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/** converts string representation into generic value
|
|
|
|
|
|
|
|
If you want to convert values whose string representation does not depend
|
|
|
|
on a concrete property, use this version
|
|
|
|
|
|
|
|
@return <TRUE/>
|
|
|
|
if and only if the value could be converted
|
|
|
|
*/
|
2015-04-15 13:17:16 +02:00
|
|
|
static bool convertStringToGenericValue(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& _rStringRep,
|
2007-07-06 07:55:00 +00:00
|
|
|
uno::Any& _rValue,
|
|
|
|
const uno::Type& _rTargetType
|
|
|
|
);
|
|
|
|
|
|
|
|
/** uses the simple convert method from the type converter
|
|
|
|
*
|
|
|
|
* \param _rValue the value to be converted
|
|
|
|
* \return the converted string.
|
|
|
|
*/
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString convertSimpleToString( const uno::Any& _rValue );
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
/** converts a string into his constant value if it exists, otherwise the type converter is used.
|
|
|
|
* \param _rValue the value to be converted
|
2017-03-02 12:27:41 +01:00
|
|
|
* \param _ePropertyType the type of the property to be converted into
|
2007-07-06 07:55:00 +00:00
|
|
|
* \return the converted value
|
|
|
|
*/
|
2013-04-07 12:06:47 +02:00
|
|
|
uno::Any convertStringToSimple( const OUString& _rValue,const uno::TypeClass& _ePropertyType );
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
uno::Reference< uno::XComponentContext > m_xContext;
|
|
|
|
uno::Reference< script::XTypeConverter > m_xTypeConverter;
|
|
|
|
uno::Reference< reflection::XConstantsTypeDescription > m_xTypeDescription;
|
2013-04-07 12:06:47 +02:00
|
|
|
uno::Sequence< OUString > m_aValues;
|
2007-07-06 07:55:00 +00:00
|
|
|
uno::Sequence< uno::Reference< reflection::XConstantTypeDescription> > m_aConstants;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
}
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
StringRepresentation::StringRepresentation(uno::Reference< uno::XComponentContext > const & context) :
|
|
|
|
m_xContext(context)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// com.sun.star.uno.XServiceInfo:
|
2017-01-26 12:28:58 +01:00
|
|
|
OUString SAL_CALL StringRepresentation::getImplementationName()
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
return comp_StringRepresentation::_getImplementationName();
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Bool SAL_CALL StringRepresentation::supportsService(OUString const & serviceName)
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
2013-10-22 11:47:01 -02:00
|
|
|
return cppu::supportsService(this, serviceName);
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
uno::Sequence< OUString > SAL_CALL StringRepresentation::getSupportedServiceNames()
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
return comp_StringRepresentation::_getSupportedServiceNames();
|
|
|
|
}
|
|
|
|
|
|
|
|
// inspection::XStringRepresentation:
|
2017-01-26 12:28:58 +01:00
|
|
|
OUString SAL_CALL StringRepresentation::convertToControlValue(const uno::Any & PropertyValue)
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sReturn;
|
2007-07-06 07:55:00 +00:00
|
|
|
if ( !convertGenericValueToString( PropertyValue, sReturn ) )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
sReturn = convertSimpleToString( PropertyValue );
|
|
|
|
#ifdef DBG_UTIL
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( sReturn.isEmpty() && PropertyValue.hasValue() )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2017-05-26 10:58:42 +02:00
|
|
|
SAL_WARN( "extensions.propctrlr", "StringRepresentation::convertPropertyValueToStringRepresentation: cannot convert values of type '"
|
|
|
|
<< PropertyValue.getValueType().getTypeName()
|
|
|
|
<< "'!" );
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
#endif
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
return sReturn;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
uno::Any SAL_CALL StringRepresentation::convertToPropertyValue(const OUString & ControlValue, const uno::Type & ControlValueType)
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
uno::Any aReturn;
|
|
|
|
|
|
|
|
uno::TypeClass ePropertyType = ControlValueType.getTypeClass();
|
|
|
|
switch ( ePropertyType )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_FLOAT:
|
|
|
|
case uno::TypeClass_DOUBLE:
|
|
|
|
case uno::TypeClass_BYTE:
|
|
|
|
case uno::TypeClass_SHORT:
|
|
|
|
case uno::TypeClass_LONG:
|
|
|
|
case uno::TypeClass_HYPER:
|
|
|
|
case uno::TypeClass_UNSIGNED_SHORT:
|
|
|
|
case uno::TypeClass_UNSIGNED_LONG:
|
|
|
|
case uno::TypeClass_UNSIGNED_HYPER:
|
|
|
|
try
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
aReturn = convertStringToSimple(ControlValue, ePropertyType);
|
|
|
|
}
|
|
|
|
catch( const script::CannotConvertException& ) { }
|
|
|
|
catch( const lang::IllegalArgumentException& ) { }
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
bool bCanConvert =
|
|
|
|
#endif
|
|
|
|
convertStringToGenericValue( ControlValue, aReturn, ControlValueType );
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
// could not convert ...
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( !bCanConvert && !ControlValue.isEmpty() )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2017-05-26 10:58:42 +02:00
|
|
|
SAL_WARN( "extensions.propctrlr", "StringRepresentation::convertStringRepresentationToPropertyValue: cannot convert into values of type '"
|
|
|
|
<< ControlValueType.getTypeName() << "'!" );
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
2013-08-19 14:10:41 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
// This comparison functor assumes an underlying set of constants with pairwise
|
|
|
|
// unequal values that are all of UNO SHORT or LONG type:
|
|
|
|
struct CompareConstants {
|
|
|
|
bool operator ()(
|
|
|
|
css::uno::Reference< css::reflection::XConstantTypeDescription > const &
|
|
|
|
c1,
|
|
|
|
css::uno::Reference< css::reflection::XConstantTypeDescription > const &
|
|
|
|
c2) const
|
|
|
|
{
|
|
|
|
return c1->getConstantValue().get<sal_Int32>()
|
|
|
|
< c2->getConstantValue().get<sal_Int32>();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
// lang::XInitialization:
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL StringRepresentation::initialize(const uno::Sequence< uno::Any > & aArguments)
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nLength = aArguments.getLength();
|
|
|
|
if ( nLength )
|
|
|
|
{
|
|
|
|
const uno::Any* pIter = aArguments.getConstArray();
|
|
|
|
m_xTypeConverter.set(*pIter++,uno::UNO_QUERY);
|
|
|
|
if ( nLength == 3 )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sConstantName;
|
2007-07-06 07:55:00 +00:00
|
|
|
*pIter++ >>= sConstantName;
|
|
|
|
*pIter >>= m_aValues;
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
if ( m_xContext.is() )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
uno::Reference< container::XHierarchicalNameAccess > xTypeDescProv(
|
2013-06-29 21:24:12 +02:00
|
|
|
m_xContext->getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
|
2007-07-06 07:55:00 +00:00
|
|
|
uno::UNO_QUERY_THROW );
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
m_xTypeDescription.set( xTypeDescProv->getByHierarchicalName( sConstantName ), uno::UNO_QUERY_THROW );
|
2014-10-28 16:50:02 +00:00
|
|
|
uno::Sequence<
|
2013-08-19 14:10:41 +02:00
|
|
|
uno::Reference< reflection::XConstantTypeDescription > >
|
|
|
|
cs(m_xTypeDescription->getConstants());
|
|
|
|
std::sort(cs.begin(), cs.end(), CompareConstants());
|
2014-10-28 16:50:02 +00:00
|
|
|
m_aConstants = cs;
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString StringRepresentation::convertSimpleToString( const uno::Any& _rValue )
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sReturn;
|
2007-07-06 07:55:00 +00:00
|
|
|
if ( m_xTypeConverter.is() && _rValue.hasValue() )
|
|
|
|
{
|
|
|
|
try
|
INTEGRATION: CWS pbrwuno (1.3.88); FILE MERGED
2005/12/19 12:22:19 fs 1.3.88.6: #i53095# also allow for BYTE sequences
2005/10/24 08:42:07 fs 1.3.88.5: start making the handlers full-fledged components, with using a new infrastructure replacing extensions/source/inc/componentmodule.*
2005/10/17 12:20:20 fs 1.3.88.4: make StringListField exchange a sequence< string >
2005/10/05 07:11:39 fs 1.3.88.3: RESYNC: (1.3-1.4); FILE MERGED
2005/08/18 12:44:35 fs 1.3.88.2: #i53095#, phase 2
moved (nearly) all property handling to dedicated handlers, the controller is
now simply managing a set of handlers
open issues for making the property browser completely generic:
- target page for a property - at the moment, the pbrw uses form-specific
knowledge
- relative position of properties. Again, the pbrw uses the OPropertyInfoService
which is not generic
- isComposeable for a given property. Also OPropertyInfoService-dependent ATM
- help ids of pages and the pbrw as a whole. They're hard-coded at the moment
other open issues:
everything in the code which is tagged with TOD/UNOize. Those are items which
do not immediately hinder phase 3 (real UNOization, i.e. definition of new
UNO interfaces for the handlers, the controller, and so on), but need to be
addressed in phase 4 (knit lose ends)
2005/08/09 14:00:08 fs 1.3.88.1: #i53095# phase 1:
- don't use strings to transver values between controls and introspectee, but Anys
- first version of a dedicated property handler for form-component-related properties
(not yet completed)
known regressions over previous phase:
- handlers for events not yet implemented, thus some assertions
- click handlers for form-component-related properties do not yet work,
thus the browse buttons mostly do not work
2006-03-14 10:33:17 +00:00
|
|
|
{
|
2019-05-04 17:06:38 +03:00
|
|
|
if ( m_aConstants.hasElements() )
|
INTEGRATION: CWS pbrwuno (1.3.88); FILE MERGED
2005/12/19 12:22:19 fs 1.3.88.6: #i53095# also allow for BYTE sequences
2005/10/24 08:42:07 fs 1.3.88.5: start making the handlers full-fledged components, with using a new infrastructure replacing extensions/source/inc/componentmodule.*
2005/10/17 12:20:20 fs 1.3.88.4: make StringListField exchange a sequence< string >
2005/10/05 07:11:39 fs 1.3.88.3: RESYNC: (1.3-1.4); FILE MERGED
2005/08/18 12:44:35 fs 1.3.88.2: #i53095#, phase 2
moved (nearly) all property handling to dedicated handlers, the controller is
now simply managing a set of handlers
open issues for making the property browser completely generic:
- target page for a property - at the moment, the pbrw uses form-specific
knowledge
- relative position of properties. Again, the pbrw uses the OPropertyInfoService
which is not generic
- isComposeable for a given property. Also OPropertyInfoService-dependent ATM
- help ids of pages and the pbrw as a whole. They're hard-coded at the moment
other open issues:
everything in the code which is tagged with TOD/UNOize. Those are items which
do not immediately hinder phase 3 (real UNOization, i.e. definition of new
UNO interfaces for the handlers, the controller, and so on), but need to be
addressed in phase 4 (knit lose ends)
2005/08/09 14:00:08 fs 1.3.88.1: #i53095# phase 1:
- don't use strings to transver values between controls and introspectee, but Anys
- first version of a dedicated property handler for form-component-related properties
(not yet completed)
known regressions over previous phase:
- handlers for events not yet implemented, thus some assertions
- click handlers for form-component-related properties do not yet work,
thus the browse buttons mostly do not work
2006-03-14 10:33:17 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
sal_Int16 nConstantValue = 0;
|
|
|
|
if ( _rValue >>= nConstantValue )
|
|
|
|
{
|
|
|
|
const uno::Reference< reflection::XConstantTypeDescription>* pIter = m_aConstants.getConstArray();
|
|
|
|
const uno::Reference< reflection::XConstantTypeDescription>* pEnd = pIter + m_aConstants.getLength();
|
|
|
|
for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
|
|
|
|
{
|
|
|
|
if ( (*pIter)->getConstantValue() == _rValue )
|
|
|
|
{
|
|
|
|
OSL_ENSURE(i < m_aValues.getLength() ,"StringRepresentation::convertSimpleToString: Index is not in range of m_aValues");
|
|
|
|
sReturn = m_aValues[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
INTEGRATION: CWS pbrwuno (1.3.88); FILE MERGED
2005/12/19 12:22:19 fs 1.3.88.6: #i53095# also allow for BYTE sequences
2005/10/24 08:42:07 fs 1.3.88.5: start making the handlers full-fledged components, with using a new infrastructure replacing extensions/source/inc/componentmodule.*
2005/10/17 12:20:20 fs 1.3.88.4: make StringListField exchange a sequence< string >
2005/10/05 07:11:39 fs 1.3.88.3: RESYNC: (1.3-1.4); FILE MERGED
2005/08/18 12:44:35 fs 1.3.88.2: #i53095#, phase 2
moved (nearly) all property handling to dedicated handlers, the controller is
now simply managing a set of handlers
open issues for making the property browser completely generic:
- target page for a property - at the moment, the pbrw uses form-specific
knowledge
- relative position of properties. Again, the pbrw uses the OPropertyInfoService
which is not generic
- isComposeable for a given property. Also OPropertyInfoService-dependent ATM
- help ids of pages and the pbrw as a whole. They're hard-coded at the moment
other open issues:
everything in the code which is tagged with TOD/UNOize. Those are items which
do not immediately hinder phase 3 (real UNOization, i.e. definition of new
UNO interfaces for the handlers, the controller, and so on), but need to be
addressed in phase 4 (knit lose ends)
2005/08/09 14:00:08 fs 1.3.88.1: #i53095# phase 1:
- don't use strings to transver values between controls and introspectee, but Anys
- first version of a dedicated property handler for form-component-related properties
(not yet completed)
known regressions over previous phase:
- handlers for events not yet implemented, thus some assertions
- click handlers for form-component-related properties do not yet work,
thus the browse buttons mostly do not work
2006-03-14 10:33:17 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( sReturn.isEmpty() )
|
2007-07-06 07:55:00 +00:00
|
|
|
m_xTypeConverter->convertToSimpleType( _rValue, uno::TypeClass_STRING ) >>= sReturn;
|
INTEGRATION: CWS pbrwuno (1.3.88); FILE MERGED
2005/12/19 12:22:19 fs 1.3.88.6: #i53095# also allow for BYTE sequences
2005/10/24 08:42:07 fs 1.3.88.5: start making the handlers full-fledged components, with using a new infrastructure replacing extensions/source/inc/componentmodule.*
2005/10/17 12:20:20 fs 1.3.88.4: make StringListField exchange a sequence< string >
2005/10/05 07:11:39 fs 1.3.88.3: RESYNC: (1.3-1.4); FILE MERGED
2005/08/18 12:44:35 fs 1.3.88.2: #i53095#, phase 2
moved (nearly) all property handling to dedicated handlers, the controller is
now simply managing a set of handlers
open issues for making the property browser completely generic:
- target page for a property - at the moment, the pbrw uses form-specific
knowledge
- relative position of properties. Again, the pbrw uses the OPropertyInfoService
which is not generic
- isComposeable for a given property. Also OPropertyInfoService-dependent ATM
- help ids of pages and the pbrw as a whole. They're hard-coded at the moment
other open issues:
everything in the code which is tagged with TOD/UNOize. Those are items which
do not immediately hinder phase 3 (real UNOization, i.e. definition of new
UNO interfaces for the handlers, the controller, and so on), but need to be
addressed in phase 4 (knit lose ends)
2005/08/09 14:00:08 fs 1.3.88.1: #i53095# phase 1:
- don't use strings to transver values between controls and introspectee, but Anys
- first version of a dedicated property handler for form-component-related properties
(not yet completed)
known regressions over previous phase:
- handlers for events not yet implemented, thus some assertions
- click handlers for form-component-related properties do not yet work,
thus the browse buttons mostly do not work
2006-03-14 10:33:17 +00:00
|
|
|
}
|
2011-12-10 22:14:57 +09:00
|
|
|
catch( const script::CannotConvertException& ) { }
|
|
|
|
catch( const lang::IllegalArgumentException& ) { }
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
return sReturn;
|
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
struct ConvertIntegerFromAndToString
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString operator()( sal_Int32 _rIntValue ) const
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2013-08-21 15:07:31 +02:00
|
|
|
return OUString::number( _rIntValue );
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
sal_Int32 operator()( const OUString& _rStringValue ) const
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
return _rStringValue.toInt32();
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
};
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
struct StringIdentity
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString operator()( const OUString& _rValue ) const
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
return _rValue;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
};
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
template < class ElementType, class Transformer >
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString composeSequenceElements( const Sequence< ElementType >& _rElements, const Transformer& _rTransformer )
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
2018-07-28 18:01:28 +02:00
|
|
|
OUStringBuffer sCompose;
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
// loop through the elements and concatenate the string representations of the integers
|
|
|
|
// (separated by a line break)
|
2018-11-06 10:12:29 +03:00
|
|
|
for (const auto& rElement : _rElements)
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
2018-11-06 10:12:29 +03:00
|
|
|
sCompose.append(OUString(_rTransformer(rElement)));
|
|
|
|
sCompose.append("\n");
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2018-11-06 10:12:29 +03:00
|
|
|
sCompose.stripEnd('\n');
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2018-07-28 18:01:28 +02:00
|
|
|
return sCompose.makeStringAndClear();
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
template < class ElementType, class Transformer >
|
2013-04-07 12:06:47 +02:00
|
|
|
void splitComposedStringToSequence( const OUString& _rComposed, Sequence< ElementType >& _out_SplitUp, const Transformer& _rTransformer )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
_out_SplitUp.realloc( 0 );
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( _rComposed.isEmpty() )
|
2007-07-06 07:55:00 +00:00
|
|
|
return;
|
|
|
|
sal_Int32 tokenPos = 0;
|
|
|
|
do
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
_out_SplitUp.realloc( _out_SplitUp.getLength() + 1 );
|
2015-03-29 15:13:23 +02:00
|
|
|
_out_SplitUp[ _out_SplitUp.getLength() - 1 ] = static_cast<ElementType>(_rTransformer( _rComposed.getToken( 0, '\n', tokenPos ) ));
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
while ( tokenPos != -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
bool StringRepresentation::convertGenericValueToString( const uno::Any& _rValue, OUString& _rStringRep )
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
bool bCanConvert = true;
|
|
|
|
|
|
|
|
switch ( _rValue.getValueTypeClass() )
|
|
|
|
{
|
|
|
|
case uno::TypeClass_STRING:
|
|
|
|
_rValue >>= _rStringRep;
|
|
|
|
break;
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_BOOLEAN:
|
|
|
|
{
|
2014-04-30 11:46:15 +02:00
|
|
|
bool bValue = false;
|
2007-07-06 07:55:00 +00:00
|
|
|
_rValue >>= bValue;
|
2017-06-11 20:56:30 +01:00
|
|
|
_rStringRep = bValue ? PcrRes(RID_RSC_ENUM_YESNO[1])
|
|
|
|
: PcrRes(RID_RSC_ENUM_YESNO[0]);
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
break;
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
// some sequence types
|
|
|
|
case uno::TypeClass_SEQUENCE:
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aStringValues;
|
2007-07-06 07:55:00 +00:00
|
|
|
Sequence< sal_Int8 > aInt8Values;
|
|
|
|
Sequence< sal_uInt16 > aUInt16Values;
|
|
|
|
Sequence< sal_Int16 > aInt16Values;
|
|
|
|
Sequence< sal_uInt32 > aUInt32Values;
|
|
|
|
Sequence< sal_Int32 > aInt32Values;
|
|
|
|
|
|
|
|
// string sequences
|
|
|
|
if ( _rValue >>= aStringValues )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
_rStringRep = composeSequenceElements( aStringValues, StringIdentity() );
|
|
|
|
}
|
|
|
|
// byte sequences
|
|
|
|
else if ( _rValue >>= aInt8Values )
|
|
|
|
{
|
|
|
|
_rStringRep = composeSequenceElements( aInt8Values, ConvertIntegerFromAndToString() );
|
|
|
|
}
|
|
|
|
// uInt16 sequences
|
|
|
|
else if ( _rValue >>= aUInt16Values )
|
|
|
|
{
|
|
|
|
_rStringRep = composeSequenceElements( aUInt16Values, ConvertIntegerFromAndToString() );
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
// Int16 sequences
|
|
|
|
else if ( _rValue >>= aInt16Values )
|
|
|
|
{
|
|
|
|
_rStringRep = composeSequenceElements( aInt16Values, ConvertIntegerFromAndToString() );
|
|
|
|
}
|
|
|
|
// uInt32 sequences
|
|
|
|
else if ( _rValue >>= aUInt32Values )
|
|
|
|
{
|
|
|
|
_rStringRep = composeSequenceElements( aUInt32Values, ConvertIntegerFromAndToString() );
|
|
|
|
}
|
|
|
|
// Int32 sequences
|
|
|
|
else if ( _rValue >>= aInt32Values )
|
|
|
|
{
|
|
|
|
_rStringRep = composeSequenceElements( aInt32Values, ConvertIntegerFromAndToString() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bCanConvert = false;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
break;
|
|
|
|
case uno::TypeClass_CONSTANT:
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
int i = 0;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
break;
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
// some structs
|
|
|
|
case uno::TypeClass_STRUCT:
|
2011-03-12 11:29:14 +01:00
|
|
|
OSL_FAIL( "StringRepresentation::convertGenericValueToString(STRUCT): this is dead code - isn't it?" );
|
2014-05-06 23:25:13 +02:00
|
|
|
if ( _rValue.getValueType().equals( cppu::UnoType< util::Date >::get() ))
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
// weird enough, the string representation of dates, as used
|
|
|
|
// by the control displaying dates, and thus as passed through the layers,
|
|
|
|
// is YYYYMMDD.
|
|
|
|
util::Date aUnoDate;
|
|
|
|
_rValue >>= aUnoDate;
|
|
|
|
_rStringRep = ::dbtools::DBTypeConversion::toDateString(aUnoDate);
|
|
|
|
}
|
2014-05-06 23:25:13 +02:00
|
|
|
else if ( _rValue.getValueType().equals( cppu::UnoType< util::Time >::get() ))
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
// similar for time (HHMMSSHH)
|
|
|
|
util::Time aUnoTime;
|
|
|
|
_rValue >>= aUnoTime;
|
|
|
|
_rStringRep = ::dbtools::DBTypeConversion::toTimeString(aUnoTime);
|
|
|
|
}
|
2014-05-06 23:25:13 +02:00
|
|
|
else if ( _rValue.getValueType().equals( cppu::UnoType< util::DateTime >::get() ))
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
util::DateTime aUnoDateTime;
|
|
|
|
_rValue >>= aUnoDateTime;
|
|
|
|
_rStringRep = ::dbtools::DBTypeConversion::toDateTimeString(aUnoDateTime);
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
else
|
|
|
|
bCanConvert = false;
|
2004-11-16 11:12:56 +00:00
|
|
|
break;
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
default:
|
|
|
|
bCanConvert = false;
|
|
|
|
break;
|
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
return bCanConvert;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
uno::Any StringRepresentation::convertStringToSimple( const OUString& _rValue,const uno::TypeClass& _ePropertyType )
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
uno::Any aReturn;
|
2011-12-22 15:35:41 -02:00
|
|
|
if ( m_xTypeConverter.is() && !_rValue.isEmpty() )
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-05-04 17:06:38 +03:00
|
|
|
if ( m_aConstants.hasElements() && m_aValues.hasElements() )
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString* pIter = m_aValues.getConstArray();
|
|
|
|
const OUString* pEnd = pIter + m_aValues.getLength();
|
2007-07-06 07:55:00 +00:00
|
|
|
for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
if ( *pIter == _rValue )
|
|
|
|
{
|
|
|
|
OSL_ENSURE(i < m_aConstants.getLength() ,"StringRepresentation::convertSimpleToString: Index is not in range of m_aValues");
|
2016-10-16 20:08:47 +02:00
|
|
|
aReturn = m_aConstants[i]->getConstantValue();
|
2007-07-06 07:55:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
if ( !aReturn.hasValue() )
|
|
|
|
aReturn = m_xTypeConverter->convertToSimpleType( makeAny( _rValue ), _ePropertyType );
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2011-12-10 22:14:57 +09:00
|
|
|
catch( const script::CannotConvertException& ) { }
|
|
|
|
catch( const lang::IllegalArgumentException& ) { }
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
|
|
|
return aReturn;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
bool StringRepresentation::convertStringToGenericValue( const OUString& _rStringRep, uno::Any& _rValue, const uno::Type& _rTargetType )
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
bool bCanConvert = true;
|
|
|
|
|
|
|
|
switch ( _rTargetType.getTypeClass() )
|
|
|
|
{
|
|
|
|
case uno::TypeClass_STRING:
|
|
|
|
_rValue <<= _rStringRep;
|
2004-11-16 11:12:56 +00:00
|
|
|
break;
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_BOOLEAN:
|
|
|
|
{
|
2017-06-11 20:56:30 +01:00
|
|
|
_rValue <<= PcrRes(RID_RSC_ENUM_YESNO[0]) != _rStringRep;
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_SEQUENCE:
|
|
|
|
{
|
|
|
|
uno::Type aElementType = ::comphelper::getSequenceElementType( _rTargetType );
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
switch ( aElementType.getTypeClass() )
|
|
|
|
{
|
|
|
|
case uno::TypeClass_STRING:
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aElements;
|
2016-04-12 16:39:03 +02:00
|
|
|
splitComposedStringToSequence( _rStringRep, aElements, StringIdentity() );
|
2007-07-06 07:55:00 +00:00
|
|
|
_rValue <<= aElements;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
break;
|
|
|
|
case uno::TypeClass_SHORT:
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
Sequence< sal_Int16 > aElements;
|
2016-04-12 16:39:03 +02:00
|
|
|
splitComposedStringToSequence( _rStringRep, aElements, ConvertIntegerFromAndToString() );
|
2007-07-06 07:55:00 +00:00
|
|
|
_rValue <<= aElements;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
break;
|
|
|
|
case uno::TypeClass_UNSIGNED_SHORT:
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
Sequence< sal_uInt16 > aElements;
|
2016-04-12 16:39:03 +02:00
|
|
|
splitComposedStringToSequence( _rStringRep, aElements, ConvertIntegerFromAndToString() );
|
2007-07-06 07:55:00 +00:00
|
|
|
_rValue <<= aElements;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_LONG:
|
|
|
|
{
|
|
|
|
Sequence< sal_Int32 > aElements;
|
2016-04-12 16:39:03 +02:00
|
|
|
splitComposedStringToSequence( _rStringRep, aElements, ConvertIntegerFromAndToString() );
|
2007-07-06 07:55:00 +00:00
|
|
|
_rValue <<= aElements;
|
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
break;
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_UNSIGNED_LONG:
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
Sequence< sal_uInt32 > aElements;
|
2016-04-12 16:39:03 +02:00
|
|
|
splitComposedStringToSequence( _rStringRep, aElements, ConvertIntegerFromAndToString() );
|
2007-07-06 07:55:00 +00:00
|
|
|
_rValue <<= aElements;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_BYTE:
|
2004-11-16 11:12:56 +00:00
|
|
|
{
|
2007-07-06 07:55:00 +00:00
|
|
|
Sequence< sal_Int8 > aElements;
|
2016-04-12 16:39:03 +02:00
|
|
|
splitComposedStringToSequence( _rStringRep, aElements, ConvertIntegerFromAndToString() );
|
2007-07-06 07:55:00 +00:00
|
|
|
_rValue <<= aElements;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bCanConvert = false;
|
|
|
|
break;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
case uno::TypeClass_STRUCT:
|
2011-03-12 11:29:14 +01:00
|
|
|
OSL_FAIL( "StringRepresentation::convertStringToGenericValue(STRUCT): this is dead code - isn't it?" );
|
2014-05-06 23:25:13 +02:00
|
|
|
if ( _rTargetType.equals( cppu::UnoType< util::Date >::get() ))
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
// weird enough, the string representation of dates, as used
|
|
|
|
// by the control displaying dates, and thus as passed through the layers,
|
|
|
|
// is YYYYMMDD.
|
|
|
|
|
|
|
|
_rValue <<= ::dbtools::DBTypeConversion::toDate(_rStringRep);
|
|
|
|
}
|
2014-05-06 23:25:13 +02:00
|
|
|
else if ( _rTargetType.equals( cppu::UnoType< util::Time >::get() ))
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
// similar for time (HHMMSSHH)
|
|
|
|
_rValue <<= ::dbtools::DBTypeConversion::toTime(_rStringRep);
|
|
|
|
}
|
2014-05-06 23:25:13 +02:00
|
|
|
else if ( _rTargetType.equals( cppu::UnoType< util::DateTime >::get() ))
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
_rValue <<= ::dbtools::DBTypeConversion::toDateTime(_rStringRep);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bCanConvert = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bCanConvert = false;
|
|
|
|
break;
|
2004-11-16 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
return bCanConvert;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
} // pcr
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2007-07-06 07:55:00 +00:00
|
|
|
|
|
|
|
// component helper namespace
|
|
|
|
namespace comp_StringRepresentation {
|
|
|
|
|
2017-12-08 15:58:41 +02:00
|
|
|
OUString _getImplementationName() {
|
2019-07-30 17:55:06 +02:00
|
|
|
return
|
|
|
|
"StringRepresentation";
|
2007-07-06 07:55:00 +00:00
|
|
|
}
|
|
|
|
|
2017-12-08 15:58:41 +02:00
|
|
|
uno::Sequence< OUString > _getSupportedServiceNames()
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
2015-11-15 08:43:35 +02:00
|
|
|
uno::Sequence< OUString > s { "com.sun.star.inspection.StringRepresentation" };
|
2007-07-06 07:55:00 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2017-12-08 15:58:41 +02:00
|
|
|
uno::Reference< uno::XInterface > _create(
|
2007-07-06 07:55:00 +00:00
|
|
|
const uno::Reference< uno::XComponentContext > & context)
|
|
|
|
{
|
|
|
|
return static_cast< ::cppu::OWeakObject * >(new pcr::StringRepresentation(context));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // closing component helper namespace
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-12-08 15:58:41 +02:00
|
|
|
extern "C" void createRegistryInfo_StringRepresentation()
|
2007-07-06 07:55:00 +00:00
|
|
|
{
|
|
|
|
::pcr::PcrModule::getInstance().registerImplementation(
|
|
|
|
comp_StringRepresentation::_getImplementationName(),
|
|
|
|
comp_StringRepresentation::_getSupportedServiceNames(),
|
|
|
|
comp_StringRepresentation::_create
|
|
|
|
);
|
|
|
|
}
|
2004-11-16 11:12:56 +00:00
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|