summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-12-18 14:31:14 +0100
committerTomaž Vajngerl <quikee@gmail.com>2016-12-19 21:37:46 +0000
commita538162b8b9c437ccd0f47bdb042317914118c6d (patch)
tree5305faedd2e1be27f4e1a218ccd08a412f039b28 /include
parent4a5ee9a074c94f2a0cc9733e12d5e412926633d1 (diff)
vcl: separate ImplImageTree - ImageTree singleton and public iface
ImplImageTree was used outside of VCL which is not consistent with the name and the header also contains a lot of implementation detail. This separates the implementation to ImplImageTree and the public interface and singleton to ImageTree only. Change-Id: I3a26444f0f6971a6b1d83472e9cef19c93192d3e Reviewed-on: https://gerrit.libreoffice.org/32134 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit bf5f6df9e47bd31dc052c6411f6f88ec2d4e3cea) Reviewed-on: https://gerrit.libreoffice.org/32165
Diffstat (limited to 'include')
-rw-r--r--include/vcl/BitmapTools.hxx2
-rw-r--r--include/vcl/ImageTree.hxx78
-rw-r--r--include/vcl/implimagetree.hxx151
3 files changed, 79 insertions, 152 deletions
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 51ae59a097a8..e2777d88c957 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -13,7 +13,7 @@
#include <vcl/bitmapex.hxx>
#include <tools/stream.hxx>
-#include <vcl/implimagetree.hxx>
+#include <vcl/ImageTree.hxx>
namespace vcl {
namespace bitmap {
diff --git a/include/vcl/ImageTree.hxx b/include/vcl/ImageTree.hxx
new file mode 100644
index 000000000000..80a6f3b5970c
--- /dev/null
+++ b/include/vcl/ImageTree.hxx
@@ -0,0 +1,78 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_INCLUDE_VCL_IMAGETREE_HXX
+#define INCLUDED_INCLUDE_VCL_IMAGETREE_HXX
+
+#include <sal/config.h>
+#include <vcl/dllapi.h>
+#include <vcl/bitmapex.hxx>
+
+enum class ImageLoadFlags : sal_uInt16
+{
+ NONE = 0,
+ IgnoreScalingFactor = 1,
+ IgnoreDarkTheme = 2,
+};
+
+namespace o3tl {
+template<> struct typed_flags<ImageLoadFlags>: is_typed_flags<ImageLoadFlags, 0x3> {};
+}
+
+namespace com { namespace sun { namespace star { namespace container {
+ class XNameAccess;
+}}}}
+
+class ImplImageTree;
+
+class ImageTree
+{
+private:
+ std::unique_ptr<ImplImageTree> mpImplImageTree;
+
+public:
+ ImageTree();
+
+ VCL_DLLPUBLIC static ImageTree & get();
+
+ VCL_DLLPUBLIC OUString getImageUrl(
+ OUString const & name, OUString const & style, OUString const & lang);
+
+ bool loadImage(
+ OUString const & name, OUString const & style,
+ BitmapEx & bitmap, bool localized,
+ const ImageLoadFlags eFlags = ImageLoadFlags::NONE);
+
+ bool loadDefaultImage(
+ OUString const & style,
+ BitmapEx& bitmap,
+ const ImageLoadFlags eFlags = ImageLoadFlags::NONE);
+
+ VCL_DLLPUBLIC css::uno::Reference<css::container::XNameAccess> getNameAccess();
+
+
+ /** a crude form of life cycle control (called from DeInitVCL; otherwise,
+ * if the ImplImageTree singleton were destroyed during exit that would
+ * be too late for the destructors of the bitmaps in maIconCache)*/
+ void shutdown();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/implimagetree.hxx b/include/vcl/implimagetree.hxx
deleted file mode 100644
index 3064e578999a..000000000000
--- a/include/vcl/implimagetree.hxx
+++ /dev/null
@@ -1,151 +0,0 @@
-/* -*- 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 .
- */
-
-#ifndef INCLUDED_INCLUDE_VCL_IMPLIMAGETREE_HXX
-#define INCLUDED_INCLUDE_VCL_IMPLIMAGETREE_HXX
-
-#include <sal/config.h>
-
-#include <memory>
-#include <unordered_map>
-#include <utility>
-#include <vector>
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <rtl/ustring.hxx>
-#include <vcl/bitmapex.hxx>
-#include <vcl/dllapi.h>
-#include <i18nlangtag/languagetag.hxx>
-
-namespace com { namespace sun { namespace star { namespace container {
- class XNameAccess;
-} } } }
-
-enum class ImageLoadFlags : sal_uInt16
-{
- NONE = 0,
- IgnoreScalingFactor = 1,
- IgnoreDarkTheme = 2,
-};
-
-namespace o3tl {
-
-template<> struct typed_flags<ImageLoadFlags>: is_typed_flags<ImageLoadFlags, 0x3> {};
-
-}
-
-
-class ImplImageTree {
-public:
- VCL_DLLPUBLIC static ImplImageTree & get();
-
- VCL_DLLPUBLIC OUString getImageUrl(
- OUString const & name, OUString const & style, OUString const & lang);
-
- bool loadImage(
- OUString const & name, OUString const & style,
- BitmapEx & bitmap, bool localized,
- const ImageLoadFlags eFlags = ImageLoadFlags::NONE);
-
- bool loadDefaultImage(
- OUString const & style,
- BitmapEx& bitmap,
- const ImageLoadFlags eFlags = ImageLoadFlags::NONE);
-
- /** a crude form of life cycle control (called from DeInitVCL; otherwise,
- * if the ImplImageTree singleton were destroyed during exit that would
- * be too late for the destructors of the bitmaps in maIconCache)*/
- void shutDown();
-
- css::uno::Reference< css::container::XNameAccess > getNameAccess();
-
-private:
- ImplImageTree();
-
- ~ImplImageTree();
-
- ImplImageTree(const ImplImageTree&) = delete;
- ImplImageTree& operator=(const ImplImageTree&) = delete;
-
- typedef std::unordered_map<OUString, std::pair<bool, BitmapEx>, OUStringHash> IconCache;
- typedef std::unordered_map<OUString, OUString, OUStringHash> IconLinkHash;
-
- struct IconSet
- {
- OUString maURL;
- css::uno::Reference<css::container::XNameAccess> maNameAccess;
- IconCache maIconCache;
- IconLinkHash maLinkHash;
-
- IconSet()
- {}
-
- IconSet(const OUString & rURL)
- : maURL(rURL)
- {}
- };
-
- /// Map between the theme name(s) and the content.
- typedef std::unordered_map<OUString, IconSet, OUStringHash> StyleIconSet;
-
- /// Remember all the (used) icon styles and individual icons in them.
- StyleIconSet maIconSets;
-
- /// Style used for the current operations; switches switch several times during fallback search.
- OUString maCurrentStyle;
-
- IconSet& getCurrentIconSet()
- {
- return maIconSets[maCurrentStyle];
- }
-
- bool doLoadImage(
- OUString const & name, OUString const & style,
- BitmapEx & bitmap, bool localized, const ImageLoadFlags eFlags);
-
- std::vector<OUString> getPaths(OUString const & name, LanguageTag& rLanguageTag);
-
- bool checkPathAccess();
-
- void setStyle(OUString const & rStyle);
-
- void createStyle();
-
- bool iconCacheLookup(OUString const & rName, bool bLocalized, const ImageLoadFlags eFlags, BitmapEx & rBitmap);
-
- bool findImage(std::vector<OUString> const & rPaths, BitmapEx & rBitmap, const ImageLoadFlags eFlags);
-
- void loadImageLinks();
-
- void parseLinkFile(std::shared_ptr<SvStream> const & aStream);
-
- /// Return name of a real .png according to links.txt.
- OUString const & getRealImageName(OUString const & rName);
-
-
- /** Return name of the fallback style for the provided one.
-
- Must not be cyclic :-) The last theme in the chain returns an empty string.
- */
- static OUString fallbackStyle(const OUString &rStyle);
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */